Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unchecked chrome.runtime.lastError #22

Open
kumavis opened this issue Sep 22, 2021 · 0 comments · May be fixed by #23
Open

unchecked chrome.runtime.lastError #22

kumavis opened this issue Sep 22, 2021 · 0 comments · May be fixed by #23

Comments

@kumavis
Copy link
Member

kumavis commented Sep 22, 2021

this._port.onMessage.addListener((msg: unknown) => this._onMessage(msg));
this._port.onDisconnect.addListener(() => this._onDisconnect());

Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.

needs to be handled in this way per https://stackoverflow.com/a/56787332

chrome.runtime.sendMessage('ping', response => {
    if(chrome.runtime.lastError) {
      // handle error
    } else {
      // handle response
    }
}

looks like firefox also puts the error on the port obj
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/Port

also looks like the error is handled more normally for some promise based apis, but likely not relevant to our usage of port
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/lastError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant