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

后端 未结 19 1222
一个人的身影
一个人的身影 2021-02-01 11:43

I have the following error in the Chrome Dev Tools console on every page-load of my Node/Express/React application:

Unchecked runtime.lastError: Could not es

相关标签:
19条回答
  • 2021-02-01 12:43

    Solution

    For Chrome:

    1. You have the window open with the console error, open up a second new window.

    2. In the second window, go to: chrome://extensions

    3. Disable each extension by toggling (the blue slider on the bottom right of each card), and refresh the window with the console after toggling each extension.

    4. Once you don't have the error, remove the extension.

    0 讨论(0)
  • 2021-02-01 12:43

    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"));
    });
    
    0 讨论(0)
  • 2021-02-01 12:43

    This is usually caused by an extension.

    If you don't want to disable or remove the extension which causes this error, you can filter out this specific error by typing -/^Unchecked\sruntime\.lastError\:\sCould\snot\sestablish\sconnection\.\sReceiving\send\sdoes\snot\sexist\.$/ in the Filter box in the console:

    As far as I've seen, this filter will stay until you remove it manually, you can close and reopen the console, restart Chrome, etc as much as you want and the filter will never be removed automatically.

    0 讨论(0)
  • 2021-02-01 12:47

    I was testing my extension on edge://extensions/ page/tab. Testing it on another tab solved this issue. I think this may also occur for chrome://extensions/.

    0 讨论(0)
  • 2021-02-01 12:47

    Oddly enough, for myself I simply disabled all my extensions and the error went away.

    However, after re-enabling all of the ones I disabled, the error was still gone.

    0 讨论(0)
  • 2021-02-01 12:48

    This was happening in Chrome for me and I discovered it was McAfee WebAdvisor. Once I disabled it, the message went away:

    0 讨论(0)
提交回复
热议问题