Open Garito opened 4 years ago
From my investigation you always need to call sendResponse callback in corresponding onMessage.attachListener to avoid this error. Or you could return some promise from it if if you want to handle message in async manner. https://developer.chrome.com/extensions/runtime#event-onMessage Probably before some moment of time calling back was not mandatory.
There is a big discussion in other plyfill library: https://github.com/mozilla/webextension-polyfill/issues/130 As I could see pollyfill authors just ignored this type of errors at the pollyfill level.
Yeah Can you show an example? I thought this library's main point is to avoid the callback hell...
const asyncFunctionWithAwait = async (request, sender, sendResponse) => {...}
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
asyncFunctionWithAwait(request, sender, sendResponse)
return true
})
worked for me
It appears that onMessage
is not fully supported by this library. I switched to https://github.com/mozilla/webextension-polyfill which seems to cover more of the API surface, including onMessage
.
Hi! I get this error:
trying to send a message to background.js like:
Can someone help figuring out what is the reason or how to use this feature properly?
Thanks