Repository navigation
Route connected web resources through controlling Service Workers #308
Description
Parent resource issue: #266
Nested-webview epic: #264
Related CSS URL decoding: #286
Proven gap
Merged #303/#304 route explicit Window.fetch() through the claimed Service Worker, but parser and DOM connected-resource loads still call the host text loader directly. <script src>, <link rel="stylesheet">, <img src>, and CSS image loads therefore bypass the controlling worker. Unchanged VS Code's webview prelude supplies its extension script, styles, and images through the v6 Service Worker broker, so explicit-fetch success cannot render Markdown content.
The generic owner is WebScene's connected-resource/request scheduling. CSS escape decoding remains #286 and CSS cascade work remains under #235.
Scope
- Route same-scope parser and dynamically connected script, stylesheet, image, and CSS image requests through the active controller before any host fallback/cache read.
- Preserve browser task ordering: script execution then load/error, stylesheet application then load/error, image decode/currentSrc/natural size then load/error.
- Carry GET URL, origin/referrer, credentials/cookie policy, destination, client identity, and navigation generation into FetchEvent.
- Keep interception asynchronous so a Service Worker may message its controlled client for bytes without blocking that client's task queue.
- Fall through only when FetchEvent is not handled. A handled rejection, timeout, malformed/oversized body, non-success status, retired generation, or stopped worker must fail closed and must not reach the host loader.
- Keep data/blob/object URLs and service-worker bootstrap loading on their existing appropriate paths.
Acceptance
- WPT-derived and Chromium contracts cover parser-created and dynamically inserted
script, stylesheet, SVG/PNG image, CSS image, load/error ordering, destinations, URL resolution, an unhandled fallthrough, and a handled failure. - An unchanged-Code-shaped worker performs CacheStorage empty-match, client
load-resourcemessaging, streamed/chunk response, and supplies prelude JS/CSS/image bytes without consumer-specific code. - Cross-origin/out-of-scope requests, retired navigation generations, traversal-shaped URLs, malformed responses, bodies over 64 MiB, and late worker replies cannot bypass admission or fall through after
respondWith. - At most 32 intercepted bodies remain active; queue/body caps from Stream and cache admitted Code OSS webview resources #266 are preserved. Navigation, unregister, and shutdown leave zero pending parser-resource fetches or retained client/DOM generations.
- A 64 KiB warm intercepted resource reaches dispatch-to-ready at p95 <= 100 ms. A 100-cycle script/style/image create-load-remove test retains <= 8 MiB V8 heap and <= 64 MiB RSS after warm-up; publish native and Chromium timings.
- Exact unchanged VS Code
645f29cMarkdown Preview advances through prelude JS, extension CSS, and a deterministic local image using the current copiedvscode-demo/README.md; remaining HTTP range/cache/security or nested-document blockers stay explicitly assigned to Stream and cache admitted Code OSS webview resources #266/Enforce secure nested-document lifecycle for Code OSS webviews #267. - No changes land in Reduce theme-fetch promise continuation latency during workbench startup #297 theme-continuation, Keep the IndexedDB bootstrap below the MSVC literal limit #301 IndexedDB portability, Make retained inset length parsing portable below macOS 26 #302/Make retained inset parsing portable on macOS #306 numeric parser, or [Epic] CSS features, compatibility, validation, and performance #235/Decode CSS string and url() escapes before resource resolution #286 CSS parsing ownership.
Proposed focused PR
One generic asynchronous connected-resource interception tranche with native/browser contracts and bounded lifecycle/performance evidence. Keep #266 open for HTTP 200/206/304/range/validator security and cumulative product completion.
Activity
wieslawsoltes commentedon Sep 17, 2026
First implementation slice published
#310 at source head
3f662378implements the smallest complete asynchronous connected-element tranche:Request.destinationpropagation and client-generation ownership;Evidence on exact main
26431500:This does not close #308. Initial navigation/parser-blocking styles and scripts, nested frame hydration resources, and CSS
url()image requests remain. They require their own asynchronous state-machine integration; CSS escape decoding remains #286. Exact unchanged Markdown acceptance remains cumulative in #266.wieslawsoltes commentedon Sep 17, 2026
Final connected-resource slice published
PR #337 at source head
466d7b79completes the remaining #308 CSS-image and cumulative Markdown-preview scope on exact main5d869353.url()images use the existing asynchronous controlled-resource queue withdestination=image.<base>changesbaseURI, fixing the Fix live per-document effective base invalidation #336 regression that brokeclients.claim().645f29cv6 worker is byte-identical (411abe3177fe8a7fb355bdf310b12b3938d5476e509dd1fb59d5c621ffd5fad0) and the copied README hash ise3194ef2de9a279c774755aefe6ed0598d3b078433513063f3f159175c0f6cc6.Focused evidence:
wieslawsoltes commentedon Sep 17, 2026
Final rebased PR head is
c3bfde5d1b79812752269a56d7f82a985c2d2af5on exact main5d86935319702942b501381de4cefcb6a46d9811.Post-amend direct gates: