Skip to content

Conversation

@spencerstock
Copy link
Contributor

@spencerstock spencerstock commented Jun 13, 2025

Summary

Connection Management:

  • Added WebSocket instance tracking to prevent event handling from stale connections
  • Fresh WebSocket creation on reconnection instead of reusing failed instances
  • Instance management to enable quicker + more reliable reconnections
  • Reconnection
    • backoff (0s first attempt, then 3s delay)
    • Prevent concurrent reconnection attempts

Heartbeat Improvements:

  • Fixed heartbeat timer management by properly clearing intervals on disconnect
  • Added connection state check before sending heartbeats to prevent errors
  • Reset lastHeartbeatResponse on disconnect to prevent false timeout detection on reconnection
  • Send immediate heartbeat after connection establishment for faster connection validation

Browser Event Handling:

  • Added visibility change and focus event handlers to detect when users returns to the app
  • Tighten up reconnect when tab/window regains focus

How did you test your changes?

Failure 1 (before fixes)

commercefail1.mp4

Failure 2 (before fixes)

commercefail2.mp4

Success with fixes

commercesuccess1.mp4

@cb-heimdall
Copy link
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@spencerstock spencerstock changed the base branch from master to felix/3.9.4 June 13, 2025 18:14
@spencerstock spencerstock force-pushed the spencer/sdk/3.9.6 branch 6 times, most recently from e1ca664 to fc22bb4 Compare June 13, 2025 18:46
@spencerstock spencerstock changed the base branch from felix/3.9.4 to arjun/3.9.5 June 13, 2025 19:07

// Check if WebSocket is actually open before sending
if (webSocket.readyState !== WebSocket.OPEN) {
this.pendingData.push(data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe i dont fully understand the life cycle of this class, but if we are constructing new WLWS for new connection, think we are losing this object level pendingData?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WalletLinkWebsocket is kind of a wrapper around the actual websocket

so
WalletLinkWebsocket
has a:

  • websocket
  • pendingData array

and only the internal websocket is reconstructed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty for correcting me here - there are places we re-instantiate the whole class. Discussed a path forward.

Copy link
Contributor

@fan-zhang-sv fan-zhang-sv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thx Spencer for tackling this issue!

@fan-zhang-sv fan-zhang-sv changed the title Spencer/sdk/3.9.6 [DO NOT MERGE] Spencer/sdk/3.9.6 Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants