tab content automatically reloads after background service worker restart #1927
Unanswered
garretwilson
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Something is reloading the current tab's content whenever my background service worker is restarted, and I need to find out how to disable this behavior.
My understanding is that under MV3 the background service worker may periodically shut down as part of its normal life cycle. Thus a web extension's background script needs to be able to restore state and continue where it left off in these circumstances.
I wanted to test this state-restoration functionality in my web extension, so on the Chrome devtools "Application > Service Workers" screen, I manually stopped the service worker. Then in my extension I sent a message to the background thread to wake it up again. The background script woke and printed a message to the console as I instructed it to. But then the browser immediately reloaded the current browser page, even though I didn't ask it to. And I can't see anything that would have caused the page to reload. Note that I'm testing with
npm run dev.Is WXT (coupled with Vite) the culprit that is reloading the current tab whenever the background service worker restarts? How can I disable this? I of course want WXT to reload the contents when the content script is edited, or perhaps even when I edit the background script. But the stop-on-idle and restart-on-activity of the background thread is part of the normal lifecycle of the background script, and that should not cause a page reload.
Perhaps I'm missing something. Is manually stopping the background service worker somehow different than the normal idle shutdown of the background service worker? (If so, then how do I test background script shutdown/restart with state restoration?) Or is something other than WXT reloading the content when the background service worker starts up again?
Beta Was this translation helpful? Give feedback.
All reactions