Skip to content

test(cache): keep the backend's early answer to an upload in the e2e proxy - #985

Merged
wan9chi merged 1 commit into
mainfrom
claude/e2e-proxy-early-answer
Nov 9, 2026
Merged

wan9chi merged 1 commit into
mainfrom
claude/e2e-proxy-early-answer

Conversation

@wan9chi

@wan9chi wan9chi commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Motivation

remote_cache::upload_without_token failed on #969's macOS CI (job). The test expects the backend's 401 Invalid credentials for an upload without a token. Instead vp run got HTTP status 502, and remote-cache-server stop reported POST /store failed: write EPIPE. The test predates the dry-run stack; the race is in the e2e proxy that sits in front of the backend.

Changes

  • The proxy streamed each request body to the backend as it arrived (request.pipe(upstream)). The Worker rejects an upload by its headers and answers 401 before reading the body. workerd then closes the connection, resetting it when body bytes are still unread.
  • On a slow runner, a later piece of the body reached the proxy after that reset but before the proxy had read the 401. Writing it failed with EPIPE, Node destroyed the socket with the 401 still unread, and the proxy answered 502.
  • The proxy now reads the whole request first and sends it with upstream.end(body). The body then goes out together with the headers, before the backend can answer, and an error after the answer is ignored, as before.

🤖 Generated with Claude Code


Note

Low Risk
Changes only the e2e remote-cache proxy’s request forwarding; production cache paths are unaffected.

Overview
Fixes a race in the e2e remote-cache proxy where uploads without a token were reported as 502 instead of the backend’s early 401.

The tap no longer streams the client body with request.pipe(upstream). It buffers the full request, then sends it with upstream.end(Buffer.concat(body)) so headers and body reach the Worker before it can reject and reset the connection. Comments now describe that reset-after-answer behavior and why late body writes could drop the unread 401.

Reviewed by Cursor Bugbot for commit e63c3be. Bugbot is set up for automated code reviews on this repo. Configure here.

…proxy

The remote cache e2e proxy streamed each request body to the backend as
it arrived. The Worker rejects an upload without a token by its headers,
answering 401 before it reads the body, and then closes the connection,
which resets it if body bytes are still unread. On a slow runner, a later
piece of the body could reach the proxy after that reset but before the
proxy read the 401. Writing it failed with EPIPE, Node destroyed the
socket with the 401 unread, and the proxy answered 502, so
`remote_cache::upload_without_token` failed on macOS CI.

The proxy now reads the whole request before forwarding it, so the body
goes out with the headers before the backend can answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wan9chi
wan9chi added this pull request to stack #987 November 9, 2026 12:04
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  +0.72%  [ -3.89% ..  +5.74%]  overhead   +61.18%
dynamic/access             change  -0.78%  [ -5.30% ..  +3.43%]  overhead   +19.82%
dynamic/access-relative    change  +0.00%  [ -3.38% ..  +3.47%]  overhead   +68.54%
dynamic/access-contended   change  +1.06%  [ -7.34% .. +10.11%]  overhead   +28.35%
static/launch              change  -0.70%  [ -6.14% ..  +5.74%]  overhead  +195.78%
static/access              change  +0.50%  [ -9.58% .. +17.00%]  overhead +1458.78%
static/access-relative     change  -0.51%  [-12.03% ..  +2.90%]  overhead +1930.66%
static/access-contended    change  -0.56%  [ -2.26% ..  +0.67%]  overhead +1673.96%

macos

dynamic/launch             change  -0.14%  [ -7.89% ..  +6.88%]  overhead  +236.16%
dynamic/access             change  -0.38%  [ -9.08% ..  +7.97%]  overhead    +4.07%
dynamic/access-relative    change  -1.19%  [ -6.45% ..  +5.24%]  overhead  +234.56%
dynamic/access-contended   change  +0.00%  [ -6.09% .. +12.97%]  overhead    +3.08%

windows

dynamic/launch             change  -0.29%  [ -2.54% ..  +1.88%]  overhead   +33.92%
dynamic/access             change  +0.00%  [ -0.62% ..  +0.21%]  overhead    +1.27%
dynamic/access-relative    change  +0.00%  [ -0.62% ..  +0.62%]  overhead    +1.70%
dynamic/access-contended   change  +0.00%  [ -0.41% ..  +0.41%]  overhead    +1.46%

@wan9chi
wan9chi merged commit 0bffa54 into main Nov 9, 2026
23 checks passed
@wan9chi
wan9chi deleted the claude/e2e-proxy-early-answer branch November 9, 2026 12:56
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.

1 participant