Skip to content

test(realtime): close pending TCP sockets during handshake cleanup - #19

Merged
moonyue-w merged 1 commit into
mainfrom
codex/fix-realtime-test-cleanup
Oct 14, 2026
Merged

moonyue-w merged 1 commit into
mainfrom
codex/fix-realtime-test-cleanup

Conversation

@moonyue-w

Copy link
Copy Markdown
Collaborator

Summary

Fix the Realtime handshake-timeout test server cleanup so it closes every accepted TCP socket, including connections that have not reached HTTP Upgrade. Add a regression that opens a TCP connection without sending an upgrade request and verifies that cleanup completes and closes the peer.

Why

When the 15 ms handshake deadline expires before the server processes the upgrade, the previous cleanup misses the socket and waits indefinitely for server.close(). Node then cancels the test and subsequent cases with “Promise resolution is still pending but the event loop has already resolved”. Keep the existing timeout and error-type assertion intact.

Verification

  • npm run build
  • npm run typecheck
  • npm test
  • npm run docs:check
  • Relevant examples run or import successfully
  • Account-backed integration tests run, or not required

Commands and results (Node v22.22.2):

Regression with the old upgrade-only socket tracking: fails with cleanup stalled
node --test tests/realtime.test.mjs: 60 passed, 0 failed, 0 cancelled
npm test: 3677 passed, 0 failed, 0 cancelled
npm run typecheck: passed
npm run docs:check: passed
git diff --check: passed

Impact

  • Public API or behavior changed
  • User-facing changes added to CHANGELOG.md under Unreleased, or not applicable (explain below)
  • CommonJS, ESM, and subpath exports remain valid
  • Generated API documentation updated
  • Contract or wire-field fixtures updated
  • Go and Python parity considered
  • Migration notes added for a breaking change
  • No credentials, .env.live, logs, or generated test output committed

Only the TypeScript test harness changes. There are no SDK runtime, public API, timeout policy, fixture, or generated documentation changes, so no changelog or migration entry is needed. Examples and account-backed tests are not required for this local socket-cleanup fix. Go and Python do not use this Node test helper. Existing offline tests cover CJS, ESM, and subpath imports.

@moonyue-w
moonyue-w merged commit 2fc4e12 into main Oct 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant