How to fix 'Unchecked runtime.lastError: The message port closed before a response was received' chrome issue?

前端 未结 17 1980
孤街浪徒
孤街浪徒 2020-12-07 08:43

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.

相关标签:
17条回答
  • 2020-12-07 09:12

    In my case it was from "Automatic Backlink Checker" extension. Maybe this will help some other users to fix their problem easier. I went from disabling all of the extensions at once to disabling them one by one. This way the mole.

    Regards

    0 讨论(0)
  • 2020-12-07 09:13

    In case you're an extension developer who googled your way here trying to stop causing this error:

    The issue isn't CORB (as another answer here states) as blocked CORs manifest as warnings like -

    Cross-Origin Read Blocking (CORB) blocked cross-origin response https://www.example.com/example.html with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.

    The issue is most likely a mishandled async response to runtime.sendMessage. As MDN says:

    To send an asynchronous response, there are two options:

    • return true from the event listener. This keeps the sendResponse function valid after the listener returns, so you can call it later.
    • return a Promise from the event listener, and resolve when you have the response (or reject it in case of an error).

    When you send an async response but fail to use either of these mechanisms, the supplied sendResponse argument to sendMessage goes out of scope and the result is exactly as the error message says: your message port (the message-passing apparatus) is closed before the response was received.

    Webextension-polyfill authors have already written about it in June 2018.

    So bottom line, if you see your extension causing these errors - inspect closely all your onMessage listeners. Some of them probably need to start returning promises (marking them as async should be enough). [Thanks @vdegenne]

    0 讨论(0)
  • 2020-12-07 09:16

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

    0 讨论(0)
  • 2020-12-07 09:24

    I have answered on this.

    In my case, the problem was because of Video Downloader professional and AdBlock

    In short, this problem occurs due to some google chrome plugins

    0 讨论(0)
  • 2020-12-07 09:25

    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.

    0 讨论(0)
  • 2020-12-07 09:25

    In my case it was OneTab chrome extension.

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