Content script not loading when navigating to URL (and other issues)
Hi,
A little about me first, I'm an experienced C# dev fairly new to TS, extensions and web dev generally, so I understand the principles, but not all the specifics (JS/TS/CSS/npm etc). I realised TS would be far more comfortable than JS, and Plasmo deals with manifests, packing and deployment, which is great (except for one issue with source maps )
So my specific issues; I've got quite far with writing the logic, and I've started adding UI components to the web page and it's generally working, but there are a few things I'm not sure I've got right (Chat GPT may be misleading me):
- I get two exceptions (errors) a lot:
- 'Extension context invalidated': I understand this happens each time I save my extension and it re-creates the scripts, so the web pages need refreshing (if it doesn't happen automatically), but is it possible to stop it reaching the 'Errors' section of the Manage Extensions screen?
- 'A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received': This seems to happen if a promise is in progress when reloading the extension, but also randomly happens while debugging, but I'm not sure why.
- Related to this, I am using async a lot (it's a pattern I'm familiar with) to communicate between the content scripts and background service worker, and I'm wondering if it's better to push shared logic (relying on persistent data) to the service worker, or if that creates a bottleneck?
- The website I'm extending navigates in a way where the page does not totally refresh (it might have a name I don't know) but when the URL changes to match a content script it doesn't load. I have solved this in another extension (without Plasmo or TS) by watching tab changes in the background script and injecting the content script. Can Plasmo do this for me somehow?
I haven't published to GH yet, but can do and will probably have more questions.
Thanks
GitHub
[BUG] Sourcemaps off by 1 line · Issue #856 · PlasmoHQ/plasmo
What happened? While debugging extensions in Chrome Devtools, the sourcemaps in content scripts are off by one line. I have this experience working on 2 different extensions. In the screenshot, the...
0 Replies