philc / philc/vimium

Report (+solution) for: Uncaught (in promise) Error: Extension context invalidated.

Open
#4,757 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Use vimium on any page
  2. Reload vimium extension
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.