Using multiple `browser.runtime.onMessage.addListener`

Regarding this API:

There is missing information how this behaves if I define multiple listeners.
I’ve now few of these in multiple modules (in background script) and it works, but I’m not 100% sure it’s by design.

I would say that:

  1. all registered listeners are executed in the order the were registered
  2. if one of the listeners returns a Promise, other listeners won’t fire - that probably also means if one of them returns true or if one of them calls sendResponse (I didn’t test these two).

Is there a way to “request” update of MDN? Or could someone confirm this is the expected behavior and I will update it myself.

Is there a way to “request” update of MDN?

Yes! Visit the page in question: , hover over “Feedback” at the top and choose “Report a content problem” which will put you in the issue tracker we use for MDN content.

I agree it would be good to document this. Especially for something like the order they fire, I imagine this might be considered an implementation detail and not a thing you should rely on.

1 Like

Thank you for the info!
Reported here.

1 Like