pbz: Chunk 29 review pass — last look, honest messages, earlier death
Three independent reviews of the first cut (adversarial correctness, call-site blast radius, test-bite verification). The test verification came back clean: all 12 original tests fail against the pre-fix library and four targeted mutations are each caught. The other two found real defects, all introduced by the first cut. Critical: fail() aborted parked waiters with no final poll. Waiters run on a 10ms interval and the ws stack dispatches buffered messages and the close event in the same batch, so "device answers, then hangs up" left the answer unclaimed and reported a completed write as a failure. abort now ticks once before rejecting; collectFrames peeks before checking liveness; a wait that starts already-dead still takes one look. The premise about message specificity was backwards. undici's ErrorEvent has an empty .message and puts the cause on .error, so reading .message degraded every real death to "connection error" — which then beat the close event's richer text. Both paths now name the device and point at the recovery playbook. Our own closes are recorded when we initiate them. A real ws.close() returns with readyState CLOSING and fires close a turn later, and a send in that window silently no-ops. Measured on Node 26.5.0: send() on a CLOSING or CLOSED socket throws nothing at all, so item 1's original "throws InvalidStateError" was wrong and the truth was worse — the fire-and-forget writes silently reported success against a dead socket. PBZ-PLAN and the affected JSDoc now say so. Also: collectChunks re-arms the idle timer per claimed chunk, so a slow transfer is no longer killed by our own backstop and mislabelled idle; using() no longer re-arms on a dead connection; _getConn consults dead(); and the three discarded housekeeping claims swallow rather than throw. 192 tests, typecheck green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PZnUXRsLLnt2A7pR3X4Luj
T
Tarek Rached committed
e139720ea08e2c676a4c89641d101982ec9142eb
Parent: 56fe16a