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

Messaging: Fix async listeners #826

Merged
merged 2 commits into from
Dec 7, 2023

Conversation

mathieudutour
Copy link
Contributor

Details

This PR fixes an issue where async listeners would not work:

CS:

listen(async (req, res) => {
  if (req.name === "getTabURL") {
    await timeout(1000)
    res.send(location.href)
    return
  } else {
    res.send("ERROR")
  }
})

BGSW:

await sendToContentScript({ name: "getTabURL" }) // will return undefined

See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage#sending_an_asynchronous_response_using_sendresponse

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I agree to license this contribution under the MIT LICENSE
  • I checked the current PR for duplication.

Copy link
Contributor

@louisgv louisgv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 - weird I thought we had the true return?!

@louisgv louisgv added this pull request to the merge queue Dec 7, 2023
Merged via the queue into PlasmoHQ:main with commit beaaf3e Dec 7, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants