Repository navigation
Conversation
lsquic read "error code != 0" as "an error is recorded". A close with code 0 that came in through lsquic_conn_abort_error (an application close, or a transport close with a reason) lost its code and type in immediate_close() and went out as a transport CONNECTION_CLOSE with INTERNAL_ERROR. Record the error with a flag of its own in struct conn_err. The same line in immediate_close() is also changed by the lsquic patch of #44846, which has to rebase onto this.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe lsquic patch tracks recorded errors separately from their numeric codes. The build applies the patch. Endpoint tests check peer results for zero-code application and transport closes, and for a nonzero application code. ChangesQUIC close error handling
Suggested reviewers: Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
|
Updated 12:59 PM PT - Oct 18th, 2026
✅ @robobun, your commit 86e9f53281d01966cbce05dbea0ecea04ea2d86d passed in 🧪 To try this PR locally: bunx bun-pr 45702That installs a local version of the PR into your bun-45702 --bun |
… the test timeout
|
Closing as stale: this PR conflicts with main, and its last commit is from 2026-10-18. The branch stays, so the work is not lost. To pick it up again, rebase the branch on main and reopen this PR. |
Fixes #45499
Problem
session.close({ code: 0n, type: "application" })andsession.destroy(undefined, { code: 0n, type: "application" })send a transport CONNECTION_CLOSE (0x1c) withINTERNAL_ERROR(0x1) and the reason "connection error". The peer'sclosedrejects withERR_QUIC_TRANSPORT_ERROR errorCode=1. Node sends an application CONNECTION_CLOSE (0x1d) with code 0 and the peer'sclosedresolves. A transport close with code 0 and a reason has the same defect.immediate_close()(lsquic_full_conn_ietf.c:4236) andietf_full_conn_ci_abort_error()(:9028) readifc_error.u.err != 0as "an error is recorded". For code 0 the recorded error looks absent andimmediate_close()falls through toCONN_ERR(0, TEC_INTERNAL_ERROR).Fix
patches/lsquic/abort-error-app-code-zero.patch, adds arecordedfield tostruct conn_err. TheCONN_ERRmacro, the only writer ofifc_error, sets it. The two readers testrecordedinstead ofu.err != 0.calloced, sorecordedis 0 until an error is stored, and every store goes throughCONN_ERR. The RFC 9000 section 10.2.3 rule that turns an application close intoAPPLICATION_ERRORin a Handshake packet is unchanged.test/js/node/quic/quic-endpoint.test.ts, 8 new tests. 5 fail on bun 1.4.3 and all pass with this branch. Alsotest/js/node/quic/,test/js/bun/http/serve-http3.test.ts, and the 38 vendoredtest-quic-*close*.mjsandtest-quic-session-*.mjsfiles.code#44846).Background
vendor/lsquicis not in git. The build fetches the pinned commit and appliespatches/lsquic/*.patchin the order listed inscripts/build/deps/lsquic.ts.QuicSession::apply_close(src/runtime/node/quic/session.rs:1946) sends an application close, a nonzero code, or a reason throughlsquic_conn_abort_error.lsquic_conn_closecan only send transportNO_ERROR, so the Rust layer has no way to express an application close with code 0. The fix has to be in lsquic.lsquic_conn_abort_errorsets (the shape of node:quic: send a client's coded close before the server's first packet, ignore close options withoutcode#44846): it leavesci_abort_error's "already recorded" guard wrong, and it tracks the caller instead of the fact. A flag set where the error is stored fixes both readers.code#44846 (open, stacked on node:quic: close() waits only for opened streams, and lsquic sends no GOAWAY before HTTP/3 starts #44751) changes the same line ofimmediate_close()with|| user_abort. It has to rebase onto this PR, drop that clause, and keep its marker for the Initial-packet fallback. The second of the two lsquic patches to land would not apply otherwise.Downsides
close/destroywith{ code: 0n, type: "transport", reason }: the peer gotINTERNAL_ERROR"connection error" and now getsNO_ERRORwith the reason, as with Node. A user who relied on the rejection seesclosedresolve.struct conn_errgrows from 8 to 12 bytes.struct ietf_full_connstays 10,232 bytes (padding).lsquic_full_conn_ietf.c.o.textgrows 761 bytes in a non-LTO release compile (size), from the extra store at each of the 75ABORT_QUIETLYsites.immediate_closestays 192 instructions,ci_abort_errorgoes from 100 to 101 (objdump -d). No change per packet or per tick.Notes
Repro. The script from #45499, with bun 1.4.3:
With this branch the first two lines read
peer closed resolved.Fail-before.
USE_SYSTEM_BUN=1 bun test test/js/node/quic/quic-endpoint.test.tson 1.4.3: 5 of the 8 new tests fail (the three application code 0 cases, and transport code 0 with a reason throughclose()anddestroy()). The other three (application code 2, transport code 0 without a reason throughclose()anddestroy()) pass on both and pin the cells that do not change. The tests use a 600 s idle timeout: an idle timeout also resolvesclosed, so only a CONNECTION_CLOSE frame can pass a test inside its timeout. The fix lives inpatches/, so a checkout ofsrc/alone does not remove it.Writers of
ifc_error.ABORT_QUIETLY(75 sites, all throughCONN_ERR) and one directconn->ifc_error = CONN_ERR(1, HEC_GENERAL_PROTOCOL_ERROR)at line 3845. NoABORT_QUIETLYsite in lsquic stores code 0: all transport codes are nonzero, and HTTP/3 codes start at 0x100. So onlylsquic_conn_abort_errorcallers reach the code 0 path. All five callers are in node:quic (session.rs3,endpoint.rs2). The Bun.serve HTTP/3 server and the fetch HTTP/3 client uselsquic_conn_closeandlsquic_conn_abort.Other suites.
test/js/node/quic/27 pass.serve-http3.test.ts79 pass. 38 of 39 vendoredtest-quic-*close*.mjs/test-quic-session-*.mjspass on the debug build.test-quic-session-initial-rtt.mjsfails on the debug ASAN build with and without this change (it asserts a 10 ms RTT bound) and passes on the release binary.Measurements. Single-file release compile of
lsquic_full_conn_ietf.cwith the flags frombuild/release/build.ninjaminus-flto=thin, before and after the patch:.text97,043 to 97,804 bytes.sizeof(struct conn_err)8 to 12,sizeof(struct ietf_full_conn)10,232 both.[policy-decision:dep] gate passed · iteration 0 · 3 files touched
passes on PR (with fix)
diff hotspot
gate history · 2 passed · 0 rejected · iteration 0
evidence per changed file
root cause · written by the author bot
The lsquic connection close path used a nonzero error code as its only signal that an application or transport error had been recorded, so an application close with code 0 (or a transport close with code 0 and a reason) was treated as having no recorded error and fell through to the default transport CONNECTION_CLOSE carrying INTERNAL_ERROR (0x1) and the reason "connection error". The fix records the error type and code explicitly when lsquic_conn_abort_error is called, independent of whether the code is zero, so the close frame is built from what the caller actually supplied. An applicatio…