fix: webview - retry service worker registration and reload webview - #333833
Open
dnch13 wants to merge 2 commits into
Open
fix: webview - retry service worker registration and reload webview#333833dnch13 wants to merge 2 commits into
dnch13 wants to merge 2 commits into
Conversation
…nsient failures Service worker registration in webviews can transiently fail, e.g. with "InvalidStateError: The document is in an invalid state" when the document is not fully active during registration, which previously surfaced a fatal "Error loading webview" notification that could only be resolved by reloading the whole window. - pre/index.html: retry registration with backoff (1s/1s/2s/3s/5s) and clean up possibly corrupted service worker state (caches / registrations on desktop) between attempts. Fail fast on permanent conditions (user denied permission, InvalidStateError) since retrying cannot recover the current document. - webviewElement: on fatal service worker registration errors, reload the webview into a fresh document (up to 5 times with backoff) before surfacing the error to the user, and offer a Reload Webview action with the final error.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds layered recovery for transient webview service-worker registration failures.
Changes:
- Retries registration with backoff and state cleanup.
- Reloads failed webviews before reporting fatal errors.
- Adds a final “Reload Webview” notification action.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
webviewElement.ts |
Adds host-side reload retries and recovery notification. |
pre/index.html |
Adds registration retries and cleanup logic. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Author
|
- Clear webview caches only on desktop, where each webview has an isolated origin. In the browser, webviews share an origin, service worker, and cache storage, so clearing them would evict resources for every other open webview. Update the inline script CSP hash. - Ignore duplicate registration failure reports while a reload is already scheduled, so repeated content events from a failed document cannot exhaust the retry budget before any reload happens. - Track mount-time drag listeners in a per-mount disposable store that is cleared on each mount, so repeated remounts no longer accumulate duplicate listeners. - Guard the Reload Webview notification action against disposed or detached webviews.
Author
|
paul-cheung0607 ayo, since this fix is solving really a ridiculous problem, bet would be better if getting steamlined ASAP (just stating that process is not as important as people's time). Thank you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bugfix is related to SUPER hot issue - 125993 (Webview crash)
Service worker registration in webviews can transiently fail, e.g. with "InvalidStateError: The document is in an invalid state" when the document is not fully active during registration, which previously surfaced a fatal "Error loading webview" notification that could only be resolved by reloading the whole window.
pre/index.html: retry registration with backoff (1s/1s/2s/3s/5s) and clean up possibly corrupted service worker state (caches / registrations on desktop) between attempts. Fail fast on permanent conditions (user denied permission, InvalidStateError) since retrying cannot recover the current document.
webviewElement: on fatal service worker registration errors, reload the webview into a fresh document (up to 5 times with backoff) before surfacing the error to the user, and offer a Reload Webview action with the final error.