“Unchecked runtime.lasterror: The message port closed before a response was received” is a standard error that can be easily fixed. In this article, we will show you three possible methods to resolve this issue.
What is the root cause of this error?
When running your program, you can easily get the following error:
“Unchecked runtime.lasterror: The message port closed before a response was received”
Extensions for browsers are the leading cause of this error. For instance, whether your extension is broken or utilizing an unsupported extension. When you’re creating a custom extension, there may be difficulty with the extension code.
How To Solve “Unchecked runtime.lastError: The message port closed before a response was received” Error?
Method 1: Disable all Extension
This mistake is frequently caused by different Chrome extensions, so all you have to do to fix it is turn off all Chrome extensions and restart your project.
Open Chrome:/extensions first, and then attempt to turn off all extensions. You can also disable the specific extensions responsible for this issue by checking them once.
The list of extensions that can be the main reason for the problem is listed below. Please check whether you are using the following extensions.
- Video Downloader Professional
- BuiltWith Technology Profiler
- Stay focused
- HonorLock
- Norton Safe web
- Tampermonkey
- Piggy – Automatic Coupons & Cash Back
- Pinterest extension
- Kaspersky browser extension
- 1password extension
- MeddleMonkey
- Color Contrast Analyzer
- Google Publisher Toolbar
Method 2: Add a return statement
The error message “Unchecked runtime.lasterror: the message port closed before a response was received” can be caused by a bug in the extension code you are using to invent different custom Chrome extensions. Examine the onMessage listener code snippet in your extension code.The above error message can occur if the listener cannot properly provide the answerback.
What you should do is adding return true in the onMessage call listener to fix 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.
});
Method 3: Try using Different Browser
You can switch to another browser, such as Opera, Firefox, etc, if you are experiencing this error with the Chrome browser. As we mentioned in the First Solution, this problem is caused by an extension. To fix it, either disabling all extensions or switching browsers will be the best choice to resolve all the errors.
Conclusion
We hope your concern about “Unchecked runtime.lastError: The message port closed before a response was received” has been solved. If there are other issues, please leave your questions and comments below and share your preferred solution with us. Thanks a lot!