Skip to content

Stream host-supplied Service Worker responses with bounded backpressure #329

Description

@wieslawsoltes

Parent resource issue: #266
Nested-webview epic: #264
Parser and connected-resource routing: #308 (separate)
Local-resource admission and localhost mapping: later #266 slices

Proven boundary

Merged #303/#304 provide Service Worker client messaging and WritableStream/TransformStream primitives, and #310/#312/#323 route controlled resources with range/cache metadata and bounded final response bodies. The remaining Code OSS chunk fallback is not covered end to end: the worker posts load-resource to its controlled client, the client returns did-load-resource, ordered did-load-resource-chunk ArrayBuffers, and did-load-resource-end, and the FetchEvent consumes that response stream.

The current generic bridge bounds serialized message queues, but the TransformStream path has no meaningful writable backpressure, its readable cancellation does not retire the writer, and no contract proves malformed, duplicate, late, aborted, timed-out, or navigation-stale host replies fail closed without retaining stream state. This is the earliest remaining dependency before localResourceRoots admission can safely supply bytes.

Scope

  • Preserve product-neutral Service Worker Client/ServiceWorker postMessage delivery for metadata, transferred byte chunks, completion, and error messages.
  • Make TransformStream writer ready, desiredSize, ordered writes, close, abort, and readable cancellation enforce bounded queued work and deterministic settlement.
  • Tie host-response stream lifetime to the controlled fetch/client generation so navigation, unregister, timeout, cancellation, and shutdown reject late chunks and release pending state once.
  • Retain the existing 256-message/16 MiB message-queue, 32-response, 64 MiB response-body, and fail-closed clone/transfer bounds.
  • Keep request admission, localResourceRoots/path traversal, localhost mapping, CSS url() interception, and consumer-specific Code OSS changes outside this slice.

Acceptance

  • A WPT-derived/Chromium contract covers ordered chunk delivery, writer backpressure, close, abort/error, readable cancellation, duplicate/late completion, and browser-shaped stream/message identities.
  • A native Code-shaped contract sends load-resource from a FetchEvent to its controlled client, returns metadata plus transferred chunks/end, and observes the exact streamed response without a direct host-loader bypass.
  • Malformed/oversized chunks, unknown or stale request IDs, queue exhaustion, timed-out requests, retired client generations, unregister, and shutdown fail closed and leave zero pending host streams/messages.
  • A warm 64 KiB response reaches first byte at p95 <= 100 ms; 32 concurrent 1 MiB streamed responses finish without starvation and stay within aggregate queue/body bounds.
  • One hundred stream/abort/retire cycles retain <= 8 MiB V8 heap and remain within the focused RSS growth bound, with native and Chromium timings published.
  • No changes overlap Preserve unitless line height for generated content #322's generated-content line-height paths, Route connected web resources through controlling Service Workers #308's resource scheduling/CSS URL ownership, or consolidation PR Add Code OSS browser and native desktop compatibility #76.

Proposed focused PR

One generic host-message streaming/backpressure tranche from exact main 3e82305aa0ce9a86fde3406db23681baa873ea45, with native/browser contracts and bounded lifecycle/performance evidence. Keep #266 open for local-resource admission, localhost mapping, CSS URL resources, and cumulative Markdown acceptance.

Activity

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

Metadata

Metadata

Assignees

Labels

vscode-oss/plannedPlanned for the AppScene/WebScene VS Code OSS integration

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions