fix: prevent uncaught Claude Code bridge WebSocket errors from masking startup timeouts (#19750)
## Background A stalled Claude Code bridge WebSocket handshake could emit an uncaught cleanup error, replacing the expected startup timeout and bypassing task failure handling. ## Root Cause Startup cleanup removed the WebSocket error listener before calling `terminate()`; the reproduction confirmed that `ws` asynchronously emits an error when terminating a CONNECTING socket, leaving that error unhandled. ## Summary The pull request preserves WebSocket error and close listeners through termination cleanup, adds asynchronous termination-error regression coverage, and includes a patch changeset for `@ai-sdk/harness-claude-code`. ## Testing Regression coverage verifies that terminating a connecting socket preserves the startup timeout without an unhandled error. All 113 Claude Code package tests and all 75 CI unit tasks pass after the latest main merge. ## End-to-end Validation - `pnpm -C examples/ai-functions exec tsx src/reproduction/claude-code-connecting-cleanup-error.ts` via immutable replay exited 0 without the original uncaught-error signal. ## Related Issues Fixes #19731 Closes #19735 --------- Co-authored-by: ai-sdk-factory <308175966+ai-sdk-factory@users.noreply.github.com> Co-authored-by: JoanLaRosa <89815407+JoanLaRosa@users.noreply.github.com> Co-authored-by: Felix Arntz <felix.arntz@vercel.com>
A
ai-sdk-factory[bot] committed
ab46c30956e04593c39cecc935d92790bd095cbb
Parent: 928f018
Committed by GitHub <noreply@github.com>
on 8/27/2026, 2:54:13 PM