Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

127
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda