Skip to content

Fix test suite hanging after completion - #6

Merged
bensie merged 1 commit into
mainfrom
bensie/fix-test-suite-hang
Mar 6, 2026
Merged

Fix test suite hanging after completion#6
bensie merged 1 commit into
mainfrom
bensie/fix-test-suite-hang

Conversation

@bensie

@bensie bensie commented Mar 6, 2026

Copy link
Copy Markdown
Member

Summary

Guard the connected-message timeout creation in onopen() with an #autoReconnect check. This prevents orphaned timers from keeping the Node process alive when tests call terminate() before the WebSocket's async onopen callback fires.

Test plan

  • All 77 tests pass with coverage maintained
  • Test suite now exits cleanly without hanging
  • Connected-message timeout tests still verify the 5-second timeout behavior

Add a #closed flag to Connection that is set in close(). Check it in
onopen before creating the 5-second connected-message timeout.

This prevents orphaned timers when terminate() is called before the
async WebSocket open event fires. Because initialize() is async,
close() can run before the WebSocket is created, so the existing
clearTimeout in close() is a no-op. The #closed flag on the Connection
instance persists across that async boundary.
@bensie
bensie force-pushed the bensie/fix-test-suite-hang branch from f74415e to 2308f22 Compare March 6, 2026 02:19
@bensie
bensie merged commit f0ebf17 into main Mar 6, 2026
1 check passed
@bensie
bensie deleted the bensie/fix-test-suite-hang branch March 6, 2026 02:21
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