Skip to content

Commit f8584ee

Browse files
authored
Merge pull request #8569 from cloudflare/piscisaureus/cluster-chain-body
Read the chained response's body in the cluster test worker
2 parents df88962 + c1388fe commit f8584ee

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎src/workerd/server/tests/cluster/cluster-worker.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ export class Counter extends DurableObject {
541541
`http://do/chain?ms=${ms}&targets=${rest.join(',')}`
542542
);
543543
if (!response.ok) return response;
544+
// Until its body is read, the called DO counts as busy, and a drain
545+
// waits for it until it cancels the requests in flight.
546+
await response.arrayBuffer();
544547
}
545548
const count = ((await this.state.storage.get('count')) ?? 0) + 1;
546549
await this.state.storage.put('count', count);

‎src/workerd/server/workerd.capnp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ struct ClusterConfig {
298298
# itself that way ends only with the requests in flight. Stopping an object's Docker container
299299
# takes one of the few handoffs that run at once.
300300
#
301+
# A request to a Durable Object stays in flight until the body of its response is read, so a
302+
# caller that checks `res.ok` and drops the response keeps the object busy, and its handoff waits
303+
# for half of this timeout before it cancels the request. Read or cancel a body you don't use
304+
# (`await res.body?.cancel()`).
305+
#
301306
# The default fits within the 10 seconds that `docker stop` and Docker Compose give a container,
302307
# and the 30 seconds that Kubernetes gives a pod (`terminationGracePeriodSeconds`). Raising this,
303308
# raise the supervisor's grace period too (`docker stop -t`, `stop_grace_period`,

0 commit comments

Comments
 (0)