plasmo
plasmo copied to clipboard
[BUG] Example code in documentation throws an error. Sending a message from MAIN world CS to Background.
What happened?
Docs example of sending a message from MAIN world CS to background throws an error. When trying to send a message to background thread from MAIN world CS I get this error:
Error: Extension runtime is not available
Specifically this example in docs: https://docs.plasmo.com/framework/messaging#:~:text=contents/componentInTheMainWorld.tsx
Version
Latest
What OS are you seeing the problem on?
Windows
What browsers are you seeing the problem on?
Chrome, Microsoft Edge
Relevant log output
No response
(OPTIONAL) Contribution
- [ ] I would like to fix this BUG via a PR
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
- [X] I checked the current issues for duplicate problems.
Error: Extension runtime is not available
Any update on this issue? Thank you! After trying all sort of ways, I find that the world: "MAIN" is causing the issue for me. When I removed this from the PlasmoCSConfig the issue went away.
Same for me
@louisgv If this is called out as explicitly possible in the documentation, but doesn't work or is broken. FWIW, It's broken for me too. It seems like an easy fix to remove the example.
Awesome Framework btw.
I don't think this feature ever worked. As the error said, extension runtime is not available in the Main World. Either the document should be removed, or rewrite to suggest using sendToBackgroundViaRelay
.
For posterity, the work around is to put the data in the DOM somewhere so that it can be accessed from both a main and isolated world. It can then be sent to the background from the isolated world script. It's a pain to implement, but it works.
Same for me