ReviewOS

home-lang/home

Bun parity: close CONNECTING WebSockets safely

#394
Closed chris opened this 10 days ago ·
10 days ago

Parent: #66 Predecessor: #393

Corpus position 4207/4708: js/web/websocket/websocket-close-connecting.test.ts.

close() and terminate() during CONNECTING must synchronously enter CLOSING, asynchronously emit error then close, settle CLOSED with code 1006 / wasClean: false, cancel every pending open path, and release transport/server references so the 128-instance upstream leak matrix is collectible.

Implement this through the shared WebSocket lifecycle rather than a corpus skip. Cancellation diagnostics must use a real ErrorEvent and preserve a structured nested error with stable code, operation, phase, original ready state, cause, and source-aware stack. Add permanent exact-file and diagnostic-contract regressions. Acceptance: the unchanged upstream file is 4/4, with 0 failed, todo, unsupported, or allowed-empty cases.

10 days ago

Completed and pushed in e48e687 (fix(websocket): close connecting clients safely).

The unchanged position-4207 upstream file is 4/4 with 0 failed, todo, unsupported, or allowed-empty cases. Both CONNECTING operations synchronously enter CLOSING, cancel pending open/server/transport paths, emit a real ErrorEvent before the unclean 1006 close, reach CLOSED, and pass the full 128-instance leak matrix.

Diagnostics now retain ERR_WEBSOCKET_CLOSED_BEFORE_OPEN, operation (web.websocket.close / web.websocket.terminate), phase, original ready state, cause, and source-aware composed stack. The TypeScript rewrite also preserves ErrorEvent assertions instead of corrupting them. Permanent exact-file and two-operation structured-diagnostic regressions pass. Predecessor: #393; parent: #66.

Sign in to comment on this issue.