Skip to content

Stop reconnecting after relayer disconnect - #236

Merged
Jaydbrown merged 1 commit into
conduit-protocol:mainfrom
silentgeckoaudit3801:fix/ws-disconnect-stop-reconnect-clean-207
Jul 29, 2026
Merged

Jaydbrown merged 1 commit into
conduit-protocol:mainfrom
silentgeckoaudit3801:fix/ws-disconnect-stop-reconnect-clean-207

Conversation

@silentgeckoaudit3801

Copy link
Copy Markdown
Contributor

Summary

  • add a reconnect-enabled guard so intentional disconnect() close events do not schedule automatic reconnects
  • reset the guard when callers explicitly invoke connect() again
  • add a regression test that fires the async close event after disconnect and verifies no second WebSocket is constructed

Fixes #207.

Validation

  • git diff --check
  • rg -n "reconnectEnabled|does not reconnect after an intentional disconnect close event|onclose|WebSocket\)\.toHaveBeenCalledTimes\(1\)|relayer\.disconnect\(\)" src/relayer/WebSocketRelayer.ts src/tests/relayer-stress.test.ts
  • Not run: npm test (node_modules is absent, and I avoided installing dependencies in this environment)

Jaydbrown added a commit that referenced this pull request Jul 29, 2026
…ew works

WebSocketRelayer.establishConnection() defensively does
'try { new WebSocketCtor(url) } catch { WebSocketCtor(url) }' to tolerate
constructor styles. Arrow functions genuinely cannot be invoked with 'new'
(TypeError: not a constructor), so mocking WebSocket as
vi.fn(() => mockWs) made every single connection attempt hit the catch
fallback and call the mock a second time without 'new' — silently
doubling every WebSocket call count. Two tests already asserted an exact
call count of 1 and were failing as a result (confirmed on main before
today's #236 WebSocketRelayer changes even touched this file, so this
predates and is unrelated to that PR — it came from #237). Using a real
function expression lets 'new' succeed on the first try, matching how a
genuine WebSocket constructor behaves.
@Jaydbrown
Jaydbrown force-pushed the fix/ws-disconnect-stop-reconnect-clean-207 branch from c4fafdd to 46e7e4d Compare July 29, 2026 10:20
@Jaydbrown
Jaydbrown merged commit c573766 into conduit-protocol:main Jul 29, 2026
1 of 2 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.

Bug: WebSocketRelayer.disconnect() doesn't stop automatic reconnection

2 participants