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

sending a response for async listeners #23709

Open
opto opened this issue Jan 16, 2023 · 0 comments
Open

sending a response for async listeners #23709

opto opened this issue Jan 16, 2023 · 0 comments
Labels
Content:WebExt WebExtensions docs help wanted If you know something about this topic, we would love your help! p3 We don't have visibility when this will be addressed.

Comments

@opto
Copy link

opto commented Jan 16, 2023

MDN URL

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessageExternal

What specific section or headline is this issue about?

addListener syntax/sendResponse

What information was incorrect, unhelpful, or incomplete?

this sounds like a personal choice (but it is not, see below):

To send a response synchronously, call sendResponse before the listener function returns. To send a response asynchronously, do one of these:

My understanding is that async functions can call sync functions in their inside, so there is no reason why an async listener could not call a sync function sendResponse.

Which means the sending is ended before the next code statement in the async listener. (Sending could just be a handing over to a messaging system, like putting a letter into a physical mailbox of the postal service). No reason why that could not be done sync in the async listener, in theory? It does not seem to be forbidden by JS.

What did you expect to see?

does not work. what is written is valid only for a sync listener.

for an async listener, the message must be returned by the listener statement:

return response;

so there is no choice in this case.

So this is not personal option:

To send a response synchronously, call sendResponse before the listener function returns. To send a response asynchronously, do one of these:

and it might help to rephrase it.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
@opto opto added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jan 16, 2023
@github-actions github-actions bot added the Content:WebExt WebExtensions docs label Jan 16, 2023
@sideshowbarker sideshowbarker added help wanted If you know something about this topic, we would love your help! and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Jan 17, 2023
@rebloor rebloor added the p3 We don't have visibility when this will be addressed. label Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebExt WebExtensions docs help wanted If you know something about this topic, we would love your help! p3 We don't have visibility when this will be addressed.
Projects
None yet
Development

No branches or pull requests

3 participants