Skip to content

fix: remove ~1ms HTTP batch latency floor on Node and Bun#220

Merged
kentonv merged 1 commit into
cloudflare:mainfrom
ndisidore:fix/batch-setimmediate
Jul 23, 2026
Merged

fix: remove ~1ms HTTP batch latency floor on Node and Bun#220
kentonv merged 1 commit into
cloudflare:mainfrom
ndisidore:fix/batch-setimmediate

Conversation

@ndisidore

Copy link
Copy Markdown
Collaborator

Node and Bun clamp setTimeout(0) to a 1ms minimum, which delayed every HTTP batch request. Schedule the batch flush with setImmediate where available to yield a macrotask without the clamp, keeping setTimeout(0) as the fallback for browsers and workerd. The macrotask timing that lets the application register .then() on RPC promises before the batch is sent is preserved.

Addresses #219

Node and Bun clamp setTimeout(0) to a 1ms minimum, which delayed every HTTP batch request. Schedule the batch flush with setImmediate where available to yield a macrotask without the clamp, keeping setTimeout(0) as the fallback for browsers and workerd. The macrotask timing that lets the application register .then() on RPC promises before the batch is sent is preserved.
@changeset-bot

changeset-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 165ece4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
capnweb Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/capnweb@220

commit: 165ece4

@kentonv
kentonv merged commit 43aa384 into cloudflare:main Jul 23, 2026
6 of 7 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 23, 2026
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