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

Documentation: How sendMessage responds #66

Open
fregante opened this issue Mar 9, 2022 · 0 comments
Open

Documentation: How sendMessage responds #66

fregante opened this issue Mar 9, 2022 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@fregante
Copy link
Collaborator

fregante commented Mar 9, 2022

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Development

No branches or pull requests

1 participant