Skip to content

unchecked chrome.runtime.lastError #22

@kumavis

Description

@kumavis

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions