Sourcegraph: `Uncaught Error: Extension context invalidated` in content script after browser extension got updated

Created on 7 Jun 2019  路  4Comments  路  Source: sourcegraph/sourcegraph

Browser: Chrome Version 74.0.3729.169 (Official Build) (64-bit)

I was reviewing https://github.com/sourcegraph/sourcegraph/pull/4403/files and whenever I hovered over a symbol I only got a spinner.

Opening the console I see the following error, multiple times:

Uncaught Error: Extension context invalidated.
    at Object.send (inject.bundle.js:149)
    at MessagePort.t.onmessage (inject.bundle.js:149)
send @ inject.bundle.js:149
t.onmessage @ inject.bundle.js:149

Live footage:

extension

browser-extension bug teaweb

Most helpful comment

I believe your extension got updated :) This occurs whenever the background page is reloaded, and a new browser extension version got deployed last night. Try a hard reload and let us know if this happens again.

All 4 comments

I believe your extension got updated :) This occurs whenever the background page is reloaded, and a new browser extension version got deployed last night. Try a hard reload and let us know if this happens again.

Wow, yeah, hard reloading fixed it. Is there any way to catch this and let the user know?

We could explore listening to the onInstalled event (which is also fired on update), and disconnecting the stale content script + re-injecting when that happens. Some people have gone down that route.

There seems to be a solution: https://stackoverflow.com/a/55336841/288906

Or you can catch that error and suggest a reload

Was this page helpful?
0 / 5 - 0 ratings

Related issues

attfarhan picture attfarhan  路  3Comments

saveman71 picture saveman71  路  3Comments

keegancsmith picture keegancsmith  路  4Comments

sqs picture sqs  路  3Comments

ggilmore picture ggilmore  路  4Comments