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
Hi, I am new to extension dev, I am following the examples in background forward message, but the popup can not get the message, I am bit confused what's happening here.
Based on the code, I am expecting it should receive a response and display it, but the response is actually undefined here.
I tried the suggestion here but it is still not working.. #971
Finally got it working after debugging for the whole afternoon..
It seems the example no longer works the way it’s written—correct me if I’m wrong.
Chrome requires a synchronous return of true or false:
false: The channel closes immediately (suitable for synchronous code).
true: The channel remains open (suitable for asynchronous code).
Workaround:
Instead of making the listener async, we can return true to keep the channel open and then handle the async logic in a separate async function.
If you're using extensionApi: "chrome", you'll need to use a synchronous callback, return true, and use sendResponse as you described. The example should work just fine since it uses the webextension-polyfill, but it should be updated so it works with both APIs using sendResponse, especially since v0.20 will be changing the default.
Describe the bug
Hi, I am new to extension dev, I am following the examples in background forward message, but the popup can not get the message, I am bit confused what's happening here.
Based on the code, I am expecting it should receive a response and display it, but the response is actually undefined here.
I tried the suggestion here but it is still not working..
#971
Reproduction
https://github.com/wxt-dev/examples/tree/main/examples/background-message-forwarder
Steps to reproduce
run the example, see if you could get the response displayed
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: