Fix unhandled ECONNRESET in fake-bridge teardown — npm test exits 0 again (v0.21.8) #51

Merged
kamilkrzywda merged 1 commits from fix/spec-teardown-econnreset into main 2026-09-27 09:18:09 +02:00
Owner

CI has been red on every run since v0.21.2 (runs 77–88): all 175 tests pass, but two deterministic uncaught read ECONNRESET exceptions from src/mesh/mesh.service.spec.ts make vitest exit 1 ("Errors 2").

Root cause: the fake bridge's accepted server-side sockets had no 'error' handler. Both new watchdog specs destroy the service's client socket while data is still pending in its receive buffer (the overflow spec floods 300 KB and destroys on the first ~64 KB chunk; the garbage spec destroys back-to-back after its last write) — so the kernel sends RST instead of FIN and read ECONNRESET fires on the server-side socket with no handler → uncaught exception → run-level failure.

Fix: one no-op socket.on('error', () => {}) on accepted sockets in fake-bridge.ts's startBridge() — single registration point covering all spec files that use the fake bridge. No production code touched (fake-bridge is imported by specs only; tsconfig.build excludes **/*spec.ts, so no runtime diff → no deploy needed).

Verified: npm test exit 0 twice (175/175, no Errors block; baseline before fix was exit 1), build + oxlint green.

CI has been red on every run since v0.21.2 (runs 77–88): all 175 tests pass, but two deterministic uncaught `read ECONNRESET` exceptions from src/mesh/mesh.service.spec.ts make vitest exit 1 ("Errors 2"). Root cause: the fake bridge's accepted server-side sockets had no 'error' handler. Both new watchdog specs destroy the service's client socket while data is still pending in its receive buffer (the overflow spec floods 300 KB and destroys on the first ~64 KB chunk; the garbage spec destroys back-to-back after its last write) — so the kernel sends RST instead of FIN and `read ECONNRESET` fires on the server-side socket with no handler → uncaught exception → run-level failure. Fix: one no-op `socket.on('error', () => {})` on accepted sockets in fake-bridge.ts's startBridge() — single registration point covering all spec files that use the fake bridge. No production code touched (fake-bridge is imported by specs only; tsconfig.build excludes **/*spec.ts, so no runtime diff → no deploy needed). Verified: npm test exit 0 twice (175/175, no Errors block; baseline before fix was exit 1), build + oxlint green.
kamilkrzywda added 1 commit 2026-09-27 09:16:35 +02:00
kamilkrzywda merged commit 46d32b3553 into main 2026-09-27 09:18:09 +02:00
kamilkrzywda deleted branch fix/spec-teardown-econnreset 2026-09-27 09:18:10 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: OpenCode/MeshBot#51