https://technoteshelp.com/node-js-how-to-run-mocha-tests-written-in-typescript/

node.js – How to fix Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

node.js – How to fix Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

Id been getting the exact same error (except my app has no back-end and React front-end), and I discovered that it wasnt coming from my app, it was actually coming from the Video Speed Controller Chrome extension. If you arent using that extension, try disabling all of your extensions and then turning them back on one-by-one?

I found the same problem when developing the Chrome extensions. I finally found the key problem.

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist

The key problem is that when background.js sends a message to the active tab via chrome.tabs.sendMessage, the content.js on the page is not ready or not reloaded. When debugging. We must ensure that content.js is active. And it cannot be a page without refreshing , The old pages don not update you js itself

Here is my code:

//background.js
chrome.tabs.query({active: true, currentWindow: true},function(tabs) {
  chrome.tabs.sendMessage(tabs[0].id, {greeting: hello}, function(response) {
      console.log(response);
  });
}); 


//content.js
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
    console.log(request, sender, sendResponse);
    sendResponse(我收到你的消息了:+JSON.stringify(request));
});

node.js – How to fix Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

The error is often caused by a chrome extension.
Try disabling all your extensions, the problem should disapear.

Related posts on node js :

Leave a Reply

Your email address will not be published.