The error “Unchecked runtime.lastError: The message port closed before a response was received” is an error that is invoked whenever you are using VueJS and Laravel to build chrome extensions. Given below is the snippet of the error:
Unchecked runtime.lastError: The message port closed before a response was received
I would like to share with you the steps I took to fix the “Unchecked runtime.lastError: The message port closed before a response was received” in your project file.
Why “Unchecked runtime.lastError The message port closed before a response was received” error is seen?
The error, “Unchecked runtime.lastError: The message port closed before a response was received” is seen because; caused by the browser extensions. this error is seen when 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.
The detailed solution to fix the error “Unchecked runtime.lastError: The message port closed before a response was received”, is given below:
How to fix the error, “Unchecked runtime.lastError The message port closed before a response was received”?
To fix this error, you will have to remove the chrome extensions, which may be unsupported or corrupt. You can also add a return statement in the background message listener.
To fix the error “Unchecked runtime.lastError: The message port closed before a response was received”, is follow one of the steps given below:
Fix 1: Remove Unsupported Extension
To fix the error “Unchecked runtime.lastError: The message port closed before a response was received”, you will have to remove the chrome extensions, which may be unsupported or corrupt :
If you wish to remove the chrome extensions, which may be or have become unsupported or corrupt in the latest updates of google chrome, you will have to go to the chrome://extensions/ and disable all extensions. After following the above steps you should check if you can use chrome without getting any error message.
If you don’t get any error message, then most likely 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.
The given below list of extensions that may cause the error message, you will have to 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
The above-given list is just an example of all the reported extensions. It’s not at all necessary that you will also face the same error messages because of the above mentioned extensions. We have given the list based on our experience and the feedback we received from our users.
This should fix the error “Unchecked runtime.lastError: The message port closed before a response was received” and if you still face the error you can follow the method 2
2. Add return statement
To fix the error “Unchecked runtime.lastError: The message port closed before a response was received”, If you are a developer and using or developing any new custom chrome extension, then it is likely that there is some issue with your extension code that is the cause of the error message.
Below you will find what part of your code is the cause of the error and how to resolve it.
You will have to check the onMessage listener code snippet in your extension code. In case this listener does not return the response correctly, then it can result in the above error message.
Then you will have to add return true in the onMessage call listener to resolve the error you have been getting, add the as given below:
chrome.runtime.onMessage.addListener(function(rq, sender, sendResponse) { setTimeout(function() { sendResponse({status: true}); }, 1); returntrue; // Add return true to fix the error.});
This should fix the error “Unchecked runtime.lastError: The message port closed before a response was received”
Conclusion
To fix the error “Unchecked runtime.lastError: The message port closed before a response was received”, you will have to remove the chrome extensions, which may be unsupported or corrupt. You can also add a return statement in the background message listener