plasmo icon indicating copy to clipboard operation
plasmo copied to clipboard

[BUG] Uncaught Error: Extension context invalidated.

Open aiddroid opened this issue 1 year ago • 6 comments

What happened?

A bug happened! So many errors. I don't know why.

background.ts

import browser from 'webextension-polyfill'

browser.contextMenus.removeAll();
browser.contextMenus.create({
    id: 'test',
    title: "test",
    contexts: [
        "image",
    ]
});

browser.contextMenus.onClicked.addListener(function(info, tab) {
   // TODO
   browser.tabs.sendMessage(tab.id, {...});
});

content.ts

import browser from 'webextension-polyfill'

browser.runtime.onMessage.addListener(function(request, sender, sendResponse) {
    // Do some thing with promise.
    fetch('/api').then((res) => {
             // TODO
    }).catch();

    return true;
});

errors in file content.480c00a3.js:328 image

Version

Latest

What OS are you seeing the problem on?

No response

What browsers are you seeing the problem on?

No response

Relevant log output

No response

(OPTIONAL) Contribution

  • [ ] I would like to fix this BUG via a PR

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct
  • [X] I checked the current issues for duplicate problems.

aiddroid avatar Jan 20 '24 08:01 aiddroid

I faced the same issue while add content script. I followed everything written in documentation and still get the error :

image

Basically, I just added a console.log to check if the script is getting loaded or not. But, here is the hack. The script loads successfully its just that I was looking into the wrong console.

When you load the script, all the updates will be visible in Tabs Console not in the Extension's Console. Please check the Tabs console. I have just ignored the error. Everything is working fine.

deveshlashkari avatar Feb 16 '24 08:02 deveshlashkari

the same issue +1

JesseCHN avatar Apr 24 '24 07:04 JesseCHN

the same issue +1

jiweiyuan avatar Apr 29 '24 09:04 jiweiyuan

the same issue +1

Jonathan-Asher avatar May 01 '24 11:05 Jonathan-Asher

same

hhmy27 avatar May 09 '24 13:05 hhmy27