browser.runtime.onMessage.addListener only accepts 2 arguments
See original GitHub issuehttps://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage
The actual browser.runtime.onMessage.addListener accepts 3 arguments:, message, sender, sendResponse. However, the current implementation only accepts 2 arguments: message, sender
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
runtime.onMessage - Mozilla - MDN Web Docs
This argument is passed back to the message sender. If you have more than one onMessage() listener in the same document, then only...
Read more >runtime.sendMessage doesn't pass callback to onMessage ...
It appears that the implementation of runtime.sendMessage accepts a callback as the second argument, but doesn't actually pass it to the ...
Read more >onMessage.addListener : sendResponse
I am coding a chrome extension and have 2 JS scripts, "script.js" and "background.js". In my script.js, I am using chrome.runtime.sendMessage to ...
Read more >onMessage listener is installed multiple times in a content ...
chrome.runtime.onMessage.addListener(function(message, sender, sendResponseFn){ ...} in it will install the listener repeatedly and will thus lead to ...
Read more >runtime.onMessage
sendMessage() or (to send a message to a content script) tabs. ... The function takes a single argument, which may be any JSON-ifiable ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I landed here from Chrome Developer website where I found no mention about returning a Promise, however I gave it a try and just wanted to confirm that this works the same as calling
sendResponse:As seen in https://github.com/mozilla/webextension-polyfill/issues/386#issue-1282698182
sendResponseshould now be supported by this package.See also updated MDN documentation: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage