Repository navigation
Conversation
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
force-pushed
the
fix/ws-disconnect-stop-reconnect-clean-207
branch
from
July 29, 2026 10:20
c4fafdd to
46e7e4d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
disconnect()close events do not schedule automatic reconnectsconnect()againFixes #207.
Validation
git diff --checkrg -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.tsnpm test(node_modulesis absent, and I avoided installing dependencies in this environment)