Skip to content

Documentation: How sendMessage responds #66

Description

@fregante

sendMessage is called without callback

No error will be logged, even if the tab doesn't exist, so for these errors to appear you must pass a callback like chrome.tabs.sendMessage(2, 'hi', console.log)

Tab doesn't exist

Could not establish connection. Receiving end does not exist.

Tab didn't call chrome.runtime.onMessage.addListener

Could not establish connection. Receiving end does not exist.

onMessage listener did not call sendResponse

If the listener returns true

The error is thrown when the page is navigates away or the tab is closed.

Before Chrome 102:

The message port closed before a response was received.

In Chrome 102:

A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received

If the listener returns anything else

This error is thrown immediately:

The message port closed before a response was received.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions