Repository navigation
Conversation
When a write and its ack share a timestamp, the ack interval and RTT are both zero and the window was computed as Infinity * 0 = NaN. A NaN window never unblocks a waiting writer and never blocks a new one. Skip the window update when the interval is zero. Fixes the intermittent workerd timeout of 'applies backpressure when window fills up'.
🦋 Changeset detectedLatest commit: ac54c5a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
There was a problem hiding this comment.
✅ Approved — A small, targeted fix that skips the window update when the ack interval is zero, with a regression test; 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
🚀 Release: ✅ LGTM
A patch-level changeset is included for this bug fix to production flow-control code, and a regression test covers it.
🔒 Security: ✅ LGTM
Flow-control arithmetic only; this adds no new trust boundary or attack surface.
📖 AGENTS.md: ✅ LGTM
The change follows the existing conventions of the repository.
📋 Code Quality: ✅ LGTM
The interval > 0 guard correctly keeps the window finite, and the window is still clamped to its min/max on every path that updates it.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The changeset and the corrected test comment describe the behaviour accurately.
Reviewed commit: ac54c5a2
| // Infinity -- or NaN once multiplied by a zero RTT. A NaN window never blocks a sender | ||
| // and never unblocks one already waiting. Leave the window alone until an ack actually | ||
| // measures something. | ||
| if (interval > 0) { |
There was a problem hiding this comment.
heads up, this diff looks way scarier than it is. the only real change is this if + the comment above it, everything below just got indented a level (and one comment re-wrapped to fit). hide whitespace and it's like 10 lines
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://fix-flow-control-nan-window.pr.capnweb.com (commit ac54c5a)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
The workerd test
applies backpressure when window fills uphas been timing out in CI most of the time (example). The test is fine. The stream flow-control window can turn intoNaN.If a write and its ack get the same timestamp, the ack interval and the RTT are both zero and the window works out to
Infinity * 0. Once it'sNaN, a writer waiting on backpressure is never woken up (the hang), and later writes are never held back at all. workerd's clock only has millisecond resolution, so same-timestamp acks are common there. Node's clock is finer, which is why this never showed up on Node.The fix: when the interval is zero, leave the window as it is.
Running the whole workerd project locally, the test timed out in 7 of 30 runs before the fix and 0 of 70 after. Those runs had a temporary log line added to confirm the
NaNwindow was the cause each time. It isn't in this PR.interval > 0is enough. Everything else is already clamped to the min/max windowNaNbefore the fix. The existing workerd test covers the hang end to endminRttnever resets, so on a coarse clock a busy stream's window drifts down to the 64KB minimum. Slower, not broken, and it was already like thatThe bug has been there since streams were added in #132. Node and workerd pass locally. I didn't run the browser projects.