You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From my understanding, the code above was added to silence the error Chrome throws when a message is received by the listener but not "handled" (i.e. the listener did not return a promise).
For Chrome, this is a user error: The user must call sendResponse, even without arguments.
Unfortunately the polyfill’s workaround means that I can't distinguish between:
the tab never handled my request (if there's any listener registered)
the tab closed before my request was answered
… because in both cases, the promise will resolve with undefined.
Since the solution to this problem is simple, I suggest surfacing this error instead of ignoring it. The solution for users is:
// use an async listenerbrowser.runtime.onMessage.addListener(async(message)=>{// Handled, done});// return anything (or better, a resolved promise)browser.runtime.onMessage.addListener((message)=>{returnPromise.resolve();});
I understand however that this would be a breaking change, but the current situation means I can't use this polyfill to send long-running messages (e.g. send message, wait for HTTP response(2))
The text was updated successfully, but these errors were encountered:
Related:
webextension-polyfill/src/browser-polyfill.js
Lines 488 to 489 in f818ecb
From my understanding, the code above was added to silence the error Chrome throws when a message is received by the listener but not "handled" (i.e. the listener did not return a promise).
For Chrome, this is a user error: The user must call
sendResponse
, even without arguments.Unfortunately the polyfill’s workaround means that I can't distinguish between:
… because in both cases, the promise will resolve with
undefined
.Since the solution to this problem is simple, I suggest surfacing this error instead of ignoring it. The solution for users is:
I understand however that this would be a breaking change, but the current situation means I can't use this polyfill to send long-running messages (e.g. send message, wait for HTTP response(2))
The text was updated successfully, but these errors were encountered: