Skip to content

Fix WebSocket reconnect delay not resetting on new connect()#67

Open
hobostay wants to merge 1 commit intovercel-labs:mainfrom
hobostay:fix/ws-reconnect-delay-reset
Open

Fix WebSocket reconnect delay not resetting on new connect()#67
hobostay wants to merge 1 commit intovercel-labs:mainfrom
hobostay:fix/ws-reconnect-delay-reset

Conversation

@hobostay
Copy link
Copy Markdown

@hobostay hobostay commented May 5, 2026

Summary

  • Fix WebSocketTransport.connect() not resetting _reconnectDelay when starting a new connection
  • If a previous session had exponentially backed off to the max delay (e.g., 30s), calling connect() again would inherit that stale delay instead of starting fresh
  • _reconnectDelay is now reset to 1000 at the start of connect(), consistent with the reset that happens on onopen

How to reproduce

  1. Connect to a WebSocket server
  2. Let the connection drop and reconnect multiple times until backoff reaches 30s
  3. Close the connection manually
  4. Call connect() again — without this fix, the first reconnect attempt waits 30s instead of 1s

Test plan

  • Test connect → disconnect → reconnect cycle and verify initial delay is always 1s

🤖 Generated with Claude Code

connect() did not reset _reconnectDelay, so if a previous session
had backed off to the maximum delay (e.g. 30s), a new connect()
call would still use that stale value. Reset to 1000ms at the
start of each new connection attempt.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

if (!this.url) throw new Error("No WebSocket URL provided");

this._closed = false;
this._reconnectDelay = 1000;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Exponential backoff for WebSocket reconnection is broken because connect() unconditionally resets _reconnectDelay to 1000ms, and _scheduleReconnect() calls connect() internally.

Fix on Vercel

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