Report (+solution) for: Uncaught (in promise) Error: Extension context invalidated.
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 27k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
In Browser Extensions page:
Vimium 2.3 => Errors:
Uncaught (in promise) Error: Extension context invalidated.
To Reproduce
- Use vimium on any page
- Reload vimium extension
- Switch back to a page where vimium has been used before reloading
...the error is generated when the input focus activates some invalidated content script.
Solution
content_scripts/vimium_frontend.js
async function checkIfEnabledForUrl() {
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
if( extensionHasBeenUnloaded() ) {
console.log("handling 'Extension context invalidated' error");
return;
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
const promises = [];
promises.push(chrome.runtime.sendMessage({ handler: "initializeFrame" }));
(...)
}
Browser and Vimium version
- Vimium 2.3
- Chromium: 139.0.7258.158
- Windows 10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open content_scripts/vimium_frontend.js and inspect checkIfEnabledForUrl(); first reproduce the issue by reloading Vimium, then switch back to a previously used page. Done means the invalidated context no longer produces the reported uncaught promise error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100