[Solved] unchecked runtime.lasterror: the message port closed before a response was received.

unchecked runtime.lasterror: the message port closed before a response was received error message can occur if there is any failure while communicating information (request and response) from background javascript and client script. You can see this error message in the browser’s console window.

unchecked runtime.lasterror: the message port closed before a response was received

This error is generally caused by the browser extensions. You are using an unsupported extension or your extension may have been corrupted. If you are developing a custom extension then there may be an issue with the extension code.

In this article we will study how to get rid of unchecked runtime.lasterror: the message port closed before a response was received error message. Go through the article thoroughly to understand the causes of this error message and their possible solutions.

Solution:

The following are the three possible solutions to resolve the error message.

1. Clear cookies and cached data

Sometimes cached and cookies data can cause this error. First, try clearing this data from the browser. Select “Cookies and other site data” and “Cached images and files” while clearing the browsing data in the “Privacy and security” section of the browser.

Clear cookies and cached data to solve the message port closed before a response was received error message

2. Remove Extension

You can go to the chrome://extensions/ and disable all extensions. Now check if you can use Chrome without any error messages.

If you don’t get any error message, then there is an issue with one of the extensions. Enable extensions one by one and test them. In this way, you can identify which extension is the culprit and causing the issue and you can remove that extension. Chrome does not report explicitly which extension really causing the issue. So you have to toggle extensions one by one.

Following is the list of extensions that may cause the error message. Check if you have installed any of the below extensions.

  • 1password extension
  • Color Contrast Analyzer
  • Google Publisher Toolbar
  • Kaspersky browser extension
  • Norton Safe web
  • Tampermonkey
  • MeddleMonkey
  • Pinterest extension
  • Stay focused
  • Piggy – Automatic Coupons & Cash Back
  • BuiltWith Technology Profiler
  • HonorLock
  • Video Downloader Professional
  • React-Sight
  • Screen Capture
  • Wappalyzer
  • AdGuard
  • Free VPN for Chrome

The above list is just an example. It’s not necessary that you are also getting error messages because of the above extensions. We have given the list based on our experience and the feedback we received from our users.

Note:

A. You can use “Disable Extensions Temporarily” extensions to disable and enable all the extension with one click.

B. You can also try using chrome in incognito mode with do not allow extension setting and see if you are able to solve the issue.

If you are still getting the error message then it means there is no issue with the extension. Something else is causing the issue. Try the second solution as mentioned below and see whether it helps you.

Check Other Articles

gotoxy() function in c++

Only integer scalar arrays can be converted to a scalar index

3. Add a return statement in the background message listener

If you are a developer and using or developing any new custom Chrome extension then there may be some issue with your extension code that causes the unchecked runtime.lasterror: the message port closed before a response was received an error message. Here we have explained in detail what part of the code can cause this error message and how to resolve it.

Please check the onMessage listener code snippet in your extension code. If this listener does not return the response correctly then it can result in the above error message.

Add return true in the onMessage call listener to resolve the error as shown below:

chrome.runtime.onMessage.addListener(function(rq, sender, sendResponse) 
{
     setTimeout(function() {
        sendResponse({status: true});
    }, 1);
     return true;  // Add return true to fix the error.
});

Note:

A. For some users breakpoint in the extension code was causing the issue. They were able to get rid of error message by removing the breakpoints. So try removing the breakpoints from the code and see whether error message is disappeared.

B. Sometimes antivirus blocks the custom code execution properly that may result in the error message. So try disabling antivirus extension and see whether it solves the error.

Conclusion:

We hope that the methods mentioned above are useful and you are able to identify the extension that was causing the issue or able to fix the custom extension code. If you are still getting the unchecked runtime.lasterror: the message port closed before a response was received error message then please do mention it in the comment section or you can communicate with us using our official mail id hello.technolads@gmail.com

Thank you.

4 thoughts on “[Solved] unchecked runtime.lasterror: the message port closed before a response was received.”

Leave a Comment