Title: [Bug] Webview bootstrap blocks on Service Worker update after the expected controller is ready · Issue #8073 · coder/code-server · GitHub
Open Graph Title: [Bug] Webview bootstrap blocks on Service Worker update after the expected controller is ready · Issue #8073 · coder/code-server
X Title: [Bug] Webview bootstrap blocks on Service Worker update after the expected controller is ready · Issue #8073 · coder/code-server
Description: Existing issues I searched existing issues and PRs for the explicit registration/update wait. I did not find a matching report. Summary In this Docker deployment, extension webview initialization blocks on an explicit await registration....
Open Graph Description: Existing issues I searched existing issues and PRs for the explicit registration/update wait. I did not find a matching report. Summary In this Docker deployment, extension webview initialization b...
X Description: Existing issues I searched existing issues and PRs for the explicit registration/update wait. I did not find a matching report. Summary In this Docker deployment, extension webview initialization b...
Opengraph URL: https://github.com/coder/code-server/issues/8073
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug] Webview bootstrap blocks on Service Worker update after the expected controller is ready","articleBody":"## Existing issues\n\n- [x] I searched existing issues and PRs for the explicit registration/update wait. I did not find a matching report.\n\n## Summary\n\nIn this Docker deployment, extension webview initialization blocks on an explicit `await registration.update()` for **45.83 seconds**. The expected webview worker takes control approximately 5 ms after the update starts, but content initialization still waits for the update promise. Codex's 30-second renderer watchdog then expires. A second webview's registration also queues for approximately 45.73 seconds. Project Manager was affected as well.\n\nThis is separate from a newer Codex preload loop that also froze the entire editor UI. The preload problem is documented in the separate extension investigation below. Bounding the Service Worker update alone did **not** fix that UI freeze.\n\n## OS/Web Information\n\n- Observed: October 24, 2026.\n- LinuxServer Docker image: `4.143.1-ls373`; build time `2026-10-24T01:07:31+00:00`.\n- code-server: `4.143.1`, commit `22ddf60dbc52f164cff13620ab515086dd08c90a`; Code `1.143.1`.\n- Previous published image: `4.141.1-ls372`.\n- Browser used for measurements: Chrome for Testing `154.0.8037.97`, Linux, Playwright.\n- HTTPS deployment behind nginx, with a root PWA Service Worker.\n- Codex `openai.chatgpt`: currently `26.1021.22027`; older `26.1007.21434` was also tested during diagnosis.\n- Project Manager: `13.1.1`.\n- The deployment has UI customizations; their contribution has not been fully isolated.\n\nI have not reproduced the scheduling delay in a clean official image or established a browser-independent regression.\n\n## Steps to Reproduce (observed deployment)\n\n1. Start an authenticated browser context with empty Service Worker/cache state.\n2. Open code-server and extension webviews such as Codex and Project Manager.\n3. Record registration, explicit update, controller changes, and webview performance marks.\n4. The editor shell is available in approximately 2–5 seconds, while webview initialization remains before `content/workerReady`.\n5. Codex reports `renderer_ready_timeout` at approximately 30 seconds.\n\n## Blocking logic\n\nGenerated file:\n\n```text\nlib/vscode/out/vs/workbench/contrib/webview/browser/pre/index.html\n```\n\nRelevant original logic:\n\n```js\nnavigator.serviceWorker.register(swPath).then(async registration => {\n if (navigator.serviceWorker.controller) {\n registration = await registration.update();\n }\n // Wait for controller changes before resolving workerReady.\n});\n```\n\nThe initial controller in the measured frame was the root PWA worker, `/_static/out/browser/serviceWorker.js`. Checking for **any** controller therefore starts another update while the webview worker is still installing.\n\n| Event | Time from webview initialization |\n| --- | ---: |\n| `register()` resolves, installing worker present | 494.4 ms |\n| Explicit `update()` starts | 495.0 ms |\n| Expected webview worker takes control | 499.8 ms |\n| `update()` resolves | 46,325.4 ms |\n\nThe update waits **45.83 seconds**. The reason for the browser's long update-job scheduling remains unproven. A second webview's `register()` waits approximately **45.73 seconds**, so bounding only the explicit update does not address all observed queueing.\n\nRepresentative log:\n\n```text\nWebview renderer did not become ready elapsedMs=30002 extensionVersion=26.1021.22027 reason=renderer_ready_timeout receivedWebviewMessage=false role=sidebar stage=renderer timeoutMs=30000\n```\n\n## Was this introduced by the latest code-server update?\n\nThe operator reports that **both the previous and current images open the old Codex, and both fail after Codex is updated**. This is the operator's A/B observation, not an independently repeated full-image A/B test.\n\nSource comparisons found:\n\n- `await registration.update()` is present in VS Code `1.141.0`, `1.141.1`, and `1.143.1`.\n- Their `src/vs/workbench/contrib/webview/browser/pre/service-worker.js` files are byte-identical: SHA-256 `83c76adde3ba663433523660289f99111bf00f395ef541d567c060a6f7cc7d8e`.\n- code-server `v4.141.1...v4.143.1` changes to `patches/webview.diff` are context line-number changes.\n- Other webview host changes exist, including mounting/key-event handshake changes; the whole older bootstrap should not be copied onto the newer host.\n\nThese findings support an **existing shared bootstrap weakness exposed alongside the Codex update**, rather than a newly added `update()` wait in this code-server release. They do not exclude every possible backend regression.\n\nPrimary source references:\n\n```text\nhttps://github.com/coder/code-server/compare/v4.141.1...v4.143.1\nhttps://github.com/linuxserver/docker-code-server/releases/tag/4.141.1-ls372\nhttps://github.com/linuxserver/docker-code-server/releases/tag/4.143.1-ls373\nhttps://github.com/microsoft/vscode/blob/1.141.1/src/vs/workbench/contrib/webview/browser/pre/index.html\nhttps://github.com/microsoft/vscode/blob/1.143.1/src/vs/workbench/contrib/webview/browser/pre/index.html\nhttps://github.com/microsoft/vscode/blob/1.143.1/src/vs/workbench/contrib/webview/browser/pre/service-worker.js\n```\n\n## Local workaround and proposed direction\n\nThe original local `code-server-webview-timeout.patch` is a diagnostic workaround against this deployment's generated files (the source-level PR is narrower and does not introduce the localStorage setting):\n\n1. Reuse a registration only when its exact scope and complete active script URL match the expected worker.\n2. Register normally when no usable matching worker exists.\n3. Bound the explicit update wait to 3,000 ms by default, continuing with the matching active worker on timeout or update failure. The browser update job itself is not canceled.\n4. Still require the expected worker to control the iframe. Request a narrowly validated `clients.claim()` when necessary; controller acquisition has a separate 10-second failure timeout.\n5. Update the inline CSP hash without relaxing the CSP.\n\nLocal setting, in the code-server origin's browser console:\n\n```js\nlocalStorage.setItem('code-server.webview.swUpdateTimeoutMs', '3000');\n```\n\nReload after changing it. Values from 0 to 60,000 ms are accepted; invalid values default to 3,000. This is a local patch setting, **not an upstream option or an environment variable**. It bounds only the update wait when a matching active worker exists. It does not limit initial registration or total startup time, and timers need a responsive event loop.\n\n## Validation and limits\n\n- The shared bootstrap/worker changes were checked separately for a hanging update, controller acquisition, initial registration, syntax, and CSP consistency.\n- The final local deployment also skips Codex's pathological `modulepreload` insertion and batches unmodified startup assets into a worker-side cache. Those extension-specific mitigations are **not** included in the focused timeout patch.\n- With the combined workaround, cold-browser tests reached the Codex welcome screen in approximately **31–44 seconds**. During an actual served-page run, opening the command palette took **256 / 151 / 804 ms**, with the longest sampled main-frame evaluation taking **755 ms**.\n- The combined fix restores UI responsiveness; cold startup is still slow. Successful combined tests do not prove that the Service Worker patch alone fixes all Codex startup problems.\n- A final actual served-page run reached the welcome screen at 43,738 ms and an editable composer before the interaction test ended at 53,660 ms. Menu opens took 420 / 157 / 588 ms; the longest main-frame evaluation was 939 ms. No chat request was submitted as part of validation.\n\nWould matching-registration reuse and a bounded update wait be appropriate in this bootstrap? Should this be addressed in code-server or VS Code upstream, and what browser tracing would help identify the long update scheduling delay?\n\n\n## Independent extension preload stall (additional investigation)\n\nThis section records a separate bottleneck for triage; the shared-Service-Worker PR does **not** claim to fix it. The CPU-profile findings and deployed cold-start timings below are from the supplied diagnostic notes. The underlying CPU profile, raw timing traces, full image runtime A/B, and cache-rebuild watcher source were not included in the review bundle.\n\n\u003cdetails>\n\u003csummary>Codex preload investigation and limits\u003c/summary>\n\n## Summary\n\nAfter updating Codex, opening its sidebar can freeze the **entire code-server page**, including editor menus. CPU profiling identifies approximately **20,020 ms** in the webview preload helper while it repeatedly scans a growing live collection of `\u003clink>` elements. The new startup dependency map contains **3,203 dependencies**.\n\nThere is also an independent shared webview Service Worker update wait, described above. Fixing that wait alone did not remove the UI freeze.\n\n## Environment and version comparison\n\n- Date: October 24, 2026.\n- Codex: `openai.chatgpt` `26.1021.22027`, Linux x64.\n- Older Codex reported working by the operator: `26.1007.21434`.\n- code-server: `4.143.1`, Code `1.143.1`, LinuxServer image `4.143.1-ls373`.\n- Previous image: `4.141.1-ls372`.\n- Diagnostic browser: Chrome for Testing `154.0.8037.97`, Linux, Playwright.\n- HTTPS, nginx, remote webview resource transport.\n\nThe operator reports the same matrix on both images: old Codex works; updating Codex triggers the failure. This is operator-provided evidence. A full independent old-image runtime A/B was not performed.\n\n## Relevant assets and profile\n\n```text\nwebview/assets/index-7e47869603c2.js\nwebview/assets/app-main-765fabf054a6.js\nwebview/assets/app-initial-13f932cb2f13.js\n```\n\nThe main startup map has **3,203 dependencies**, totaling **73,088,572 bytes** of source assets. Including the entry and additional entry dependency yields 3,205 cached files and 73,228,948 source bytes. These are source-file counts/bytes, not a claim that every file is fetched independently in every browser run.\n\nThe helper obtains a live collection and scans it for each dependency while appending more links. Simplified observed structure:\n\n```js\nconst links = document.getElementsByTagName('link');\nfor (const dependency of dependencies) {\n for (let i = links.length - 1; i >= 0; i--) {\n // Check whether this dependency already has a link.\n }\n document.head.appendChild(modulePreloadLink);\n}\n```\n\nThe growing live collection makes repeated scans increasingly expensive. About **3,198 modulepreload links** were inserted in the observed run.\n\nCPU profile findings:\n\n- Approximately **20,020 ms** attributed to `app-initial-13f932cb2f13.js`, line 1, column 11,593 in the captured profile.\n- Approximately **1,708 ms** additionally attributed to `appendChild`.\n- Skipping modulepreload link insertion removes the observed 20-second hotspot in a comparison profile.\n\nThe old version's main entry, `app-main-92173aa1395c.js`, is a 539-byte initialization wrapper with direct imports. This comparison does **not** establish the old version's total transitive module count or imply it has no dependencies.\n\n## Observed behavior\n\n1. Open a fresh authenticated code-server browser context.\n2. Open the Codex sidebar in an extension-enabled workspace.\n3. Observe a long preload loop and the workbench becoming unresponsive, including menus.\n4. In some runs the 30-second renderer watchdog reports `renderer_ready_timeout`.\n\nThe diagnostic deployment uses custom workbench/UI code, and this has not yet been reproduced in a clean desktop VS Code or clean official code-server image. The profile directly identifies the expensive loop in this deployment; it does not establish why the browser schedules all frames together or that every browser has the same freeze.\n\n## Temporary mitigation and validation\n\nThe local mitigation is outside the extension installation, so installing another Codex version does not overwrite it:\n\n- Suppress only `LINK` nodes with `rel === 'modulepreload'` in the Codex inner document. Normal module imports still load.\n- Keep original JavaScript/CSS bytes and module URLs. No rebundling or extension-file edits remain.\n- Batch the current startup dependency assets into a gzip pack; the webview Service Worker serves the original module URLs from an in-memory cache. This reduces remote per-resource transport overhead.\n- Watch extension registry changes and rebuild the pack for updated versions using the same supported asset layout. Unknown layouts fail back to normal resource loading.\n\nA candidate cold-browser test reached the welcome UI at **31,077 ms**, completed the onboarding screens, and reached an editable composer. Command-palette opens during loading took **350 / 909 / 253 ms**, with the longest sampled main-frame evaluation **550 ms**. A separate actual served-page run reached the welcome UI at **37,838 ms**, with command-palette opens **256 / 151 / 804 ms**.\n\nThis restores responsiveness but does not make cold startup fast. Tests used an empty extension-enabled workspace; a fresh browser opening an untrusted folder has a separate Restricted Mode activation constraint. No prompt was submitted, and backend generation was not tested.\n\nCould the preload helper use a Set of existing URLs or another bounded lookup rather than repeatedly traversing a live collection? Can the main startup dependency graph be narrowed or loaded incrementally to avoid thousands of preload insertions and the renderer startup deadline?\n\nA final actual served-page test reached the welcome UI at **43,738 ms** and an editable composer before the interaction test ended at **53,660 ms**. Menu opens took **420 / 157 / 588 ms**, with the longest sampled main-frame evaluation **939 ms**. Cold loading therefore varied across runs; no sub-30-second startup guarantee is claimed.\n\n\u003c/details>\n\n## Checks performed while preparing this report\n\n- Independently fetched VS Code 1.141.0, 1.141.1 and 1.143.1 sources: all contain `await registration.update()`, and all three webview worker SHA-256 hashes match the value above.\n- Independently checked the code-server version comparison: the `patches/webview.diff` changes are hunk line-number updates. Both LinuxServer release tags exist.\n- Added real-Chromium regression coverage against the pinned VS Code source bootstrap and actual Service Worker implementation. This isolates worker lifecycle behavior without depending on extension activation or a compiled workbench.\n- The unpatched code-server bootstrap fails the root-controller/hanging-update regression. The proposed source patch passes the browser cases. These checks do not reproduce the original 45.83-second browser scheduling delay or the 20-second extension preload profile.\n\n## Remaining template information\n\n- Local diagnostic OS: Linux; distribution and remote CPU architecture were not recorded in the supplied notes.\n- Native VS Code: not tested.\n- VS Code web (`code serve-web`): not tested.\n- GitHub Codespaces: not tested.\n- [x] Accessed over a secure context (HTTPS through nginx).\n\nThe deployment-specific asset cache and `Node.prototype.appendChild` interception have been excluded from the proposed upstream code. They depend on extension internals and deployment paths and require separate design and validation.\n\n## Proposed source-level fix\n\nPR #8074 addresses the shared Service Worker bootstrap wait and controller acquisition. It excludes the independent Codex preload suppression and deployment-specific module cache.\n","author":{"url":"https://github.com/NevermoreN","@type":"Person","name":"NevermoreN"},"datePublished":"2026-10-24T07:42:51Z","url":"https://github.com/coder/code-server/issues/8073"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b7d1d4cc-adf9-c528-60a7-6ca1f7d3ec1f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B00:1C6B40:A0DE:CE6A:6B042EDF |
| html-safe-nonce | c12ecf289ee000a1348fccb56848ae9dc1639a695128509aa96d09d006b0f058 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjAwOjFDNkI0MDpBMERFOkNFNkE6NkIwNDJFREYiLCJ2aXNpdG9yX2lkIjoiNzU3NDkyMDA2NTI0NjgzNDM5OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 51dfc9c955a5868309de4a9ef4164752ed53e4827af51b7c05d1f60f09d18f94 |
| hovercard-subject-tag | issue:6010681817 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/code-server/8073/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4cdf139d03457862d71747fe3a5cea2fe2a8f061bc93684d9e1e8b356be53ef8/coder/code-server/issues/8073 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4cdf139d03457862d71747fe3a5cea2fe2a8f061bc93684d9e1e8b356be53ef8/coder/code-server/issues/8073 |
| og:image:alt | Existing issues I searched existing issues and PRs for the explicit registration/update wait. I did not find a matching report. Summary In this Docker deployment, extension webview initialization b... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | NevermoreN |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/code-server git https://github.com/coder/code-server.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 172953845 |
| octolytics-dimension-repository_nwo | coder/code-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 172953845 |
| octolytics-dimension-repository_network_root_nwo | coder/code-server |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width