Skip to content

Read the chained response's body in the cluster test worker - #8569

Merged
jasnell merged 1 commit into
mainfrom
piscisaureus/cluster-chain-body
Nov 20, 2026
Merged

jasnell merged 1 commit into
mainfrom
piscisaureus/cluster-chain-body

Conversation

@piscisaureus

Copy link
Copy Markdown
Contributor

In "a stopping node's DOs finish calls to themselves and across nodes",
every handoff on the stopping node waited out the 5 s allowed for
requests in flight and then cancelled them, although the calls were done
within 2 s. The test worker's /chain handler never read the body of a
chained DO's 200 response, and until it is read the called DO counts as
busy. On a loaded macOS runner that 5 s wait pushed the drain past the
harness's stop timeout, so the node was SIGKILLed: 2 of the 14 recent
slow-drain CI failures were this test.

  • /chain now reads the body of each response it gets back.
  • The stopping node's drain takes about 1.3 s instead of 5.0-5.5 s, and
    the test about 2.9 s instead of 6.3 s.

cluster-test passed 200 of 200 shard-runs on bazelflare.

Kind Lines Where
Implementation 0
Tests 3 cluster-worker.js
Documentation 0

@piscisaureus
piscisaureus requested review from a team as code owners November 18, 2026 02:54
@piscisaureus
piscisaureus requested a review from ry November 18, 2026 02:54

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of c1388fe6.

This review, of e6bfec6a

✅ Approved — The change is three lines in a test worker and no issues were found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code reviewer: ✅ LGTM

The three-line change to the test worker's /chain handler is correct and has no side effects.


Reviewed commit: e6bfec6a

@ry ry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI] LGTM. The behaviour this works around affects users too: a DO response whose body is never read keeps the DO busy, so a drain waits the full 5 s for code that checks .ok and drops the body. Maybe worth a line in the drain docs.

The /chain handler of the cluster test's Counter called the next DO
and, when that answered 200, never read the response's body. Until the
body is read, the called DO counts as busy. In "a stopping node's DOs
finish calls to themselves and across nodes" every handoff on the
stopping node so waited out the 5 s allowed for requests in flight and
then cancelled them, although the calls were done within 2 s.

* /chain now reads the body of each response it gets back.
* The stopping node's drain takes about 1.3 s instead of 5.0-5.5 s, and
  the test about 2.9 s instead of 6.3 s.
* The stopTimeoutMs docs say that an unread DO response body keeps the
  object busy and its handoff waiting, and advise reading or cancelling
  a body that isn't used.
@piscisaureus
piscisaureus force-pushed the piscisaureus/cluster-chain-body branch from e6bfec6 to c1388fe Compare November 18, 2026 23:49
@piscisaureus

Copy link
Copy Markdown
Contributor Author

Added that to the stopTimeoutMs docs in workerd.capnp (c1388fe): a response body that is never read keeps the DO busy, and its handoff waits for half of the stop timeout before it cancels the request, so read or cancel a body you do not use (await res.body?.cancel()). The 5 s in the test comes from its 10 s stopTimeoutMs; the default (8 s) gives 4 s, so the doc gives no number. Cancelling instead of reading ends the drain as fast as reading does (2.8 s vs 2.9 s, against 6.3 s for a dropped body).

@piscisaureus
piscisaureus requested a review from ry November 18, 2026 23:49

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — A three-line test worker fix plus a doc note on stopTimeoutMs. No issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code reviewer: ✅ LGTM

The /chain handler reads the chained response body once with no other effect. The stopTimeoutMs doc paragraph is consistent with the existing text about requests in flight being cancelled at half the stop timeout.


Reviewed commit: c1388fe6

@piscisaureus
piscisaureus requested a review from jasnell November 19, 2026 23:17
@jasnell
jasnell merged commit f8584ee into main Nov 20, 2026
23 checks passed
@jasnell
jasnell deleted the piscisaureus/cluster-chain-body branch November 20, 2026 01:40
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.

3 participants