How to fix 'Unchecked runtime.lastError: The m

2020-02-16 07:37发布

I'm using VueJS and Laravel for my project. This issue started to show lately and it shows even in the old git branches.

This error only shows in Chrome browser.

13条回答
Luminary・发光体
2楼-- · 2020-02-16 07:42

Disable if there is any anti-virus extension is installed on the browser. In my case, the anti-virus extension was the culprit.

查看更多
淡お忘
3楼-- · 2020-02-16 07:44

Post is rather old and not closely related to Chrome extensions development, but let it be here.

I had same problem when responding on message in callback. The solution is to return true in background message listener.

Here is simple example of background.js. It responses to any message from popup.js.

chrome.runtime.onMessage.addListener(function(rq, sender, sendResponse) {
    // setTimeout to simulate any callback (even from storage.sync)
    setTimeout(function() {
        sendResponse({status: true});
    }, 1);
    // return true;  // uncomment this line to fix error
});

Here is popup.js, which sends message on popup. You'll get exceptions until you un-comment "return true" line in background.js file.

document.addEventListener("DOMContentLoaded", () => {
    chrome.extension.sendMessage({action: "ping"}, function(resp) {
        console.log(JSON.stringify(resp));
    });
});

manifest.json, just in case :) Pay attention on alarm permissions section!

{
  "name": "TestMessages",
  "version": "0.1.0",
  "manifest_version": 2,
  "browser_action": {
    "default_popup": "src/popup.html"
  },
  "background": {
    "scripts": ["src/background.js"],
    "persistent": false
  },
  "permissions": [
    "alarms"
  ]
}
查看更多
Evening l夕情丶
4楼-- · 2020-02-16 07:45

If you go to chrome://extensions/, you can just toggle each extension one at a time and see which one is actually triggering the issue.

Once you toggle the extension off, refresh the page where you are seeing the error and wiggle the mouse around, or click. Mouse actions are the things that are throwing errors.

So I was able to pinpoint which extension was actually causing the issue and disable it.

查看更多
冷血范
5楼-- · 2020-02-16 07:45

For me it was Auto Tab Discard, which throws that error on pinned tabs. I created a bug report, https://github.com/rNeomy/auto-tab-discard/issues/101.

查看更多
爷、活的狠高调
6楼-- · 2020-02-16 07:47

For those coming here to debug this error in Chrome 73, one possibility is because Chrome 73 onwards disallows cross-origin requests in content scripts.

More reading:

  1. https://www.chromestatus.com/feature/5629709824032768
  2. https://www.chromium.org/Home/chromium-security/extension-content-script-fetches

This affects many Chrome extension authors, who now need to scramble to fix the extensions because Chrome thinks "Our data shows that most extensions will not be affected by this change."

(it has nothing to do with your app code)

UPDATE: I fixed the CORs issue but I still see this error. I suspect it is Chrome's fault here.

查看更多
唯我独甜
7楼-- · 2020-02-16 07:48

I disabled all installed extensions in Chrome - works for me. I have now clear console without errors.

查看更多
登录 后发表回答