leonvogt / hotwire-dev-tools

Dev Tools for Turbo and Stimulus
MIT License
79 stars 2 forks source link

Error: Extension context invalidated #47

Open lirtistan opened 3 weeks ago

lirtistan commented 3 weeks ago

Hi,

content.js throws errors on various sites (for whatever reason), try to reading "options" from storage.

Screenshot from 2024-06-14 08-19-44

leonvogt commented 3 weeks ago

Hi @lirtistan,

Hm I didn't noticed that till now. Do you have by any chance a way to reproduce this?
I'm happy to look into this, but can't seem to reproduce it on my machine.

lirtistan commented 3 weeks ago

Looks like the same issue as discussed here https://stackoverflow.com/questions/53939205/how-to-avoid-extension-context-invalidated-errors-when-messaging-after-an-exte

Actually content.js is always active, maybe that should be changed/limited somehow to sites where the detail_panel is really wanted by user interaction.

leonvogt commented 3 weeks ago

Actually content.js is always active, maybe that should be changed/limited somehow to sites where the detail_panel is really wanted by user interaction.

The content.js does more than rendering the detail panel. It's also responsible for highlighting elements or logging Turbo Streams to the console. Even if the detail panel isn't shown.
Therefore the content.js always needs to be active.

If someone dislikes this behaviour, you can always manage via the browser settings on which sites this extension should and shouldn't be active.

lirtistan commented 3 weeks ago

Therefore the content.js always needs to be active.

Then it needs to be refactored to be more robust, starting with surrounding await expressions with try/catch clauses, especialty if they have todo with IO operations. Do you agree with that!?

leonvogt commented 3 weeks ago

I agree that we should make it more robust, but I would prefer to first find a reproducible way to replicate the issue before starting refactoring. This way we know if our changes are actually fixing the issue.

lirtistan commented 3 weeks ago

Strange, that error just appeared on the github pages.

Sure at some point during our last tests, i also tested on github (because UI is basically RoR), so they using hotwired stuff (at least TurboFrames, afaik).

So i went to the popup.html inspector and cleared the application context (Tab Application -> Clear site data ) and the error is gone. At least he doesn't appear anymore on the github pages.

I keep searching.

Also found a new error, see #49 for details.

lirtistan commented 3 weeks ago

Ok the error showed again, seems this happens every time the extension is getting an upgrade, but still active on all sites during the upgrade process.

Happend again during testing of #50

Screenshot from 2024-06-15 12-00-20

leonvogt commented 2 weeks ago

Ok the error showed again, seems this happens every time the extension is getting an upgrade, but still active on all sites during the upgrade process.

@lirtistan Awesome that you seem to have found the root of the error! Maybe we can now find a reproducible way with this in mind.