webext-core icon indicating copy to clipboard operation
webext-core copied to clipboard

@webext-core/messaging errors with No response when sending data back from an injected script

Open rcoopr opened this issue 4 months ago • 1 comments

Using only example code from the webext-core site, injected script messaging causes an error (No error when sending messages to the injected script) Potentially related to #55 ?

Error:

Uncaught (in promise) Error: No response
    at Object.<anonymous> (chunk-ALTBYIMW.js:80:67)
    at Generator.next (<anonymous>)
    at fulfilled (chunk-ALTBYIMW.js:36:24)

Minimal repro: https://github.com/rcoopr/wxtcore-messaging-repro

  • clone
  • pnpm i
  • pnpm dev
  • check console

What steps did I do to create example:

  • init WXT using pnpm dlx wxt@latest init <project-name>
  • pnpm i @webext-core/messaging
  • Add permissions for injected script to wxt config
  • Copy code from https://webext-core.aklinker1.io/guide/messaging/#window-messaging (Also, there is a typo, browser.runtime.getUrl is actually getURL)
  • run pnpm dev and check console

The messages are recieved, yet there is an error anyway. The issue is also present in the built output. Only tested on Chrome 122

rcoopr avatar Mar 09 '24 21:03 rcoopr