Skip to content

fix(webview): bound worker updates and acquire the expected controller - #8074

Open
NevermoreN wants to merge 1 commit into
coder:mainfrom
NevermoreN:fix/webview-service-worker-update-wait
Open

NevermoreN wants to merge 1 commit into
coder:mainfrom
NevermoreN:fix/webview-service-worker-update-wait

Conversation

@NevermoreN

Copy link
Copy Markdown

Fixes #8073

When a root PWA worker controls a new webview, the bootstrap treats it as an existing webview controller and awaits another update job. That job can hold initialization beyond extension renderer deadlines even after the correct webview worker takes control. Reopening a webview can also queue register() behind a previous update.

This change reuses a registration only when its exact scope and full active script URL match, bounds its explicit update wait to three seconds, and requires the expected controller before content initialization. Initial registration is still required. Controller acquisition fails after ten seconds and removes its listeners and retry timer. Update failure can fall back only to the matching active worker. A distinct worker query parameter prevents reusing a pre-fix worker that lacks the claim handler.

The worker accepts a claim request only from a window client on the same origin at an exact outer-webview path. The patch preserves the third-party-cookie diagnostic and updates the CSP hash without relaxing the policy.

Validation:

  • 11 Chromium browser regression tests pass against the pinned, patched source bootstrap and actual workers: root PWA takeover, hanging update/register, update rejection, explicit claim, rejection of an inner-document claim, controller timeout and cleanup, mismatched script URL, permission diagnostic, disabled/unavailable workers, and CSP hash.
  • The first-registration regression fails on the unpatched bootstrap.
  • The complete quilt patch stack is checked against the pinned VS Code source files with zero fuzz; the resulting bootstrap and worker must match the browser-tested files.
  • Prettier and added-source whitespace checks pass. A standalone TypeScript checkJs run reports the same three existing diagnostics on baseline and candidate; no new diagnostics are introduced. This is not a full VS Code typecheck.

This PR does not include the deployment's Codex preload suppression or module cache. It does not claim to fix the separate extension main-thread stall, guarantee sub-30-second cold startup, or bound first registration. A full code-server build and whole-workbench extension interaction have not been run for this PR. The deployed combined-workaround timings in the issue are prior diagnostic evidence, not validation of this source patch.

Reuse matching registrations, bound update waits, validate claim requests, and cover worker lifecycle behavior in Chromium.

Fixes coder#8073

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Webview bootstrap blocks on Service Worker update after the expected controller is ready

1 participant