Skip to content

Stream proxied bodies through the worker unchanged - #5

Merged
luax merged 6 commits into
mainfrom
ludvig/proxy-stream-with-upgrade
Sep 28, 2026
Merged

luax merged 6 commits into
mainfrom
ludvig/proxy-stream-with-upgrade

Conversation

@luax

@luax luax commented Sep 28, 2026

Copy link
Copy Markdown

Proxied request and response bodies now pass through the worker as the original streams so that large uploads no longer exhaust the worker's resources and leave the isolate failing every request with 1101. This also upgrades worker to 0.8.7 so that the Wasm instance recovers after a panic.

The shim is the JavaScript entry file that worker-build generates to load the Wasm and forward requests into Rust. worker-build 0.8 now writes it as build/index.js with build/index_bg.wasm instead of build/worker/shim.mjs with index.wasm, so the CLI embeds and uploads those files instead.

The proxy converted every request and response into http types, which
copied each body chunk through Wasm memory. Large uploads (a 96 MB
Playwright trace) used seconds of CPU and hit Cloudflare's resource
limit. The runtime then terminated the request, cancelling the Wasm
executor's queued microtask, and every later request on that isolate
hung with error 1101.

Proxy requests now forward the original JS body streams in both
directions and only rewrite headers. Uploads also keep their
Content-Length instead of arriving chunked. Only /linkup routes still
go through the axum router.
worker 0.8 reinitializes the Wasm instance after a Rust panic or a
JavaScript error passes through Wasm, so one failed request no longer
leaves the isolate broken for every request that follows.

worker-build 0.8 emits build/index.js and build/index_bg.wasm, so the
CLI now embeds and uploads those instead of shim.mjs and index.wasm.
@luax
luax force-pushed the ludvig/proxy-stream-with-upgrade branch from a0089a3 to 367e6e3 Compare September 28, 2026 13:00
@luax
luax merged commit 54db789 into main Sep 28, 2026
6 checks passed
ostenbom added a commit that referenced this pull request Sep 29, 2026
PR #5 rebuilt upstream requests with the default redirect mode
(`follow`), causing the Worker to follow OAuth callback redirects
itself. The browser received the final response instead of the redirect
and its authentication cookies, breaking SSO through Linkup.

Set the upstream redirect mode to `Manual` while preserving streamed
bodies. Add a Worker integration test that verifies the 303 status,
Location header, and both Set-Cookie headers reach the client. Update
Wrangler entry points and CI placeholder artifacts to the worker-build
0.8 output paths so CI runs the current Worker.

Validation:
- The new regression test failed before the fix (200 instead of 303) and
passed afterward.
- All 11 server integration tests passed with the local Worker running
(`cargo test -p linkup-server-tests -- --include-ignored`).
- `worker-build --release`, `cargo fmt --all --check`, and `git diff
--check` passed.

The Worker needs redeploying for the fix to take effect; live Google SSO
has not been retested.
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.

2 participants