. Advertisement .
..3..
. Advertisement .
..4..
Don’t know how to tackle the message “Unchecked runtime.lasterror: could not establish connection. Receiving end does not exist.”? This guide will provide the cause behind such errors and three solutions for you to choose from.
Why Does The Error Occur?
Why does the error happen to your program? Well, the answer is simple: your main document has some issues with specific Chrome extensions. Your program fails to establish any connection, a problem many web programmers have to face during a Chrome operation.
Fortunately, the problem is not that difficult to tackle; there are only several small steps to take! Some code changes are possible, but such processes often call for extension disabling.
Now that you have understood the causes, check out our next section for solutions.
How to Fix The Error “Unchecked Runtime.Lasterror: Could Not Establish Connection. Receiving End Does Not Exist.”
Solution 1: Remove The Extension
Step 1. On the browser, navigate and open two different windows. Open the error message within your first window. How about the second window? We will use it to solve this issue.
Step 2. Use that second window to load active extensions on the browser.
Step 3. Let’s switch off and disable those extensions by adjusting the switch. Now enter the first window again to refresh that error message in your program.
Step 4. The error message will appear. Extract the extension from the browser.
And that is all the steps you must take to fix the problem! Once following them, the issue will fix itself in a blink.
Solution 2: Create Syntaxes for Solution Requests
Sometimes, the cause behind the error might lie in a message returned by JavaScript. After receiving this message, your active tab will initiate Javascript’s content on its page (despite that the document has not been loaded).
Thus, to debug the issue, ensure that the Javascript content is still running. Also, since older pages will not automatically upgrade, your page should feature active refresh cycles.
Let’s create a syntax for requests and allow your browser to fix the issue. All the values, listeners, and functions embedded in this code should alleviate your error in no time:
Example (Solution 2):
/background.js
chrome.tabs.query({active: true, currentWindow: true},function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {greeting: “hello”}, function(response) {
console.log(response);
});
});
//content.js
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){
console.log(request, sender, sendResponse);
sendResponse(‘send this:’+JSON.stringify(“request”));
});
Solution 3: Remove The Faulty Extension
Some extensions might be the reason behind your program bugs. Hence, removing those extensions is a plausible approach to get rid of that error.
For instance, let’s say the extension “Udacity Frontend Feedback” causes the “unchecked runtime.lasterror: could not establish a connection. receiving end does not exist error message” inside your program.
Fortunately, we can tweak this error with some simple codes. You need to establish a message callback handler within the syntax.
Example (Solution 3):
window.chrome.runtime.sendMessage(
EXTENSION_ID,
{ message:”—” }, // jsonable message
(result) => {
if (!window.chrome.runtime.lastError) {
// it does not work, that’s it. No more unchecked error
}
}
);
});
Conclusion
This article has shown you how to tackle the “Unchecked runtime.lasterror: could not establish connection. Receiving end does not exist”. There are three different methods, so assess your situation and skills to pick the most suited one!For similar Javascript errors (such as “Unchecked runtime.lasterror: the message port closed before a response was received”), feel free to browse ITutoria guidelines for more support.
Leave a comment