Repository navigation
fix(workerd): end connections without an unhandled rejection on older compatibility dates - #160
Merged
Merged
Conversation
okomarov
force-pushed
the
cf-close-rejections
branch
from
October 19, 2026 22:46
8e70d13 to
064e57e
Compare
… compatibility dates The cloudflare:sockets polyfill closed the socket as soon as Terminate was written. close() closes both sides, so the read that is always pending rejected. The read loop's catch handled it, but before workerd's unhandled_rejection_after_microtask_checkpoint flag (cloudflare/workerd#6020, on by default from compatibility date 2026-03-03) workerd reported the rejection as unhandled first. In the local workerd matrix, turning only that flag on at 2025-01-01 took close-time rejections from 27 to 0 across 15 scenarios, and turning it off at 2026-10-12 brought 26 back. end() with Terminate now writes it and leaves the socket open, as socket.end() does in Node: PostgreSQL closes its side, the read loop sees end of stream and the socket closes once, with no rejected read. A close without data still closes at once, with its promise handled, and the connection's close timer still bounds a server that never closes. At 2025-01-01 and 2025-09-15 without the flag, graceful scenarios (end-plain, timers, copy-out, subscribe, ssl-prefer-declined, end-tls) went from 15 rejections to 0. Forced closes (connect-timeout, end-timeout, end-while-connecting) still report one per close on those dates. Cancelling the pending read first changed nothing and hung the Node-level core-plain case, so those stay documented: move to 2026-03-03 or set the flag. The workerd runner now fails any other scenario that logs a close-time rejection, takes extra compatibility flags from WORKERD_COMPAT_FLAGS and keys expected failures per matrix entry, since tls-untrusted-ca follows the same flag. The matrix adds 2025-01-01 with the flag. Closes #1
okomarov
force-pushed
the
cf-close-rejections
branch
from
October 19, 2026 22:46
064e57e to
8e1827b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work on #1. First commit finds which compatibility flag removes the close-time rejections; the polyfill change follows once the counts are in.
Refs #1