Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
Why Shouldn't WebExtensions runtime.onMessage.addListener Function be Async?

I'm new to writing browser extensions and am working on some changes to a Firefox extension. While reading the documentation for browser.runtime.onMessage.addListener() I came across this note:

Note: If you pass an async function to addListener(), the listener will return a Promise for every message it receives, preventing other listeners from responding:

// don't do this
browser.runtime.onMessage.addListener(
  async (data, sender) => {
    if (data.type === 'handle_me') { return 'done'; }
  }
);

Despite this, however, async addListener() functions seem to be used somewhat commonly from what I can tell (at least, I've seen them in code for widely-used and well-known extensions as well as in examples provided by people on various forums threads, etc.).

Can somebody provide some details on why this should be avoided and/or whether it is only a problem in certain scenarios? It says returning a Promise for every message received will prevent other listeners from responding... does that mean this is only an issue if you have multiple listeners attached? Or is it something that should always be avoided no matter what?

Any insight is appreciated!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!