Skip to content

fix(durable-objects): buffer the request body until it has arrived before answering a fetch - #77

Merged
eersnington merged 1 commit into
mainfrom
t3/fix-durable-object-request-body-truncation
Nov 24, 2026
Merged

eersnington merged 1 commit into
mainfrom
t3/fix-durable-object-request-body-truncation

Conversation

@eersnington

Copy link
Copy Markdown
Member

Buffers a Durable Object fetch() request body in Orange, and returns from the actor's onRequest only after the whole upload has arrived. Before, an object that answered before it read the body got only its first 64 to 128 KiB, and the stream ended with no error. This broke git http-backend pushes with fatal: early EOF.

  • Root cause: RivetKit cancels the native upload in the finally of its onRequest wrapper (native.ts#L5444-L5451). The next read() returns null, so the body ends as if complete.
  • Holding the answer back cannot stall a caller: RivetKit's client sends the whole body before it waits for an answer.
  • New deviation in docs/modules/durable-objects.mdx: stub.fetch() resolves only after the body has reached the object. The old "read the body first" workaround row is removed.
  • The upstream fix belongs in RivetKit: keep the upload open until the response body finishes, and make a read after cancel error instead of returning null.

Proof: pnpm test:e2e tests/durable-objects/durable-object-streamed-body.test.ts passes. Without the fix the object gets 262144 of 8388608 bytes.

Fixes #72

…fore answering a fetch

RivetKit cancels an actor request's upload once onRequest returns, so an object that answered before it read the body got only its first 64 to 128 KiB. Orange now reads the upload into its own buffer and returns from onRequest only after all of it has arrived.

Fixes #72
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Preview removed; R2 assets deleted.

@eersnington
eersnington merged commit 13c6ac0 into main Nov 24, 2026
12 checks passed
@eersnington
eersnington deleted the t3/fix-durable-object-request-body-truncation branch November 24, 2026 22:34
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.

Durable Objects: a request body stops arriving once the object starts to answer

1 participant