Skip to content

fix(ConnectionManager): background reconnection on Android#12

Open
rabume wants to merge 1 commit into
sfourdrinier:masterfrom
rabume:master
Open

fix(ConnectionManager): background reconnection on Android#12
rabume wants to merge 1 commit into
sfourdrinier:masterfrom
rabume:master

Conversation

@rabume
Copy link
Copy Markdown

@rabume rabume commented May 10, 2026

Two issues prevented auto-reconnect from working when the app was backgrounded:

  1. connect() overwrote reconnection options set by enableAutoReconnect(), losing connectionOptions like autoConnect: true. Fixed by storing reconnect-specific options in a separate reconnectOptions field that survives connect() state replacement.

  2. setTimeout(fn, 0) never fires in background because React Native's timer implementation uses Choreographer frame callbacks tied to VSYNC. Fixed by using Promise.resolve().then() (microtask) for zero-delay scheduling, which executes on the same event loop tick.

Two issues prevented auto-reconnect from working when the app was backgrounded:

1. connect() overwrote reconnection options set by enableAutoReconnect(),
   losing connectionOptions like autoConnect: true. Fixed by storing
   reconnect-specific options in a separate reconnectOptions field that
   survives connect() state replacement.

2. setTimeout(fn, 0) never fires in background because React Native's
   timer implementation uses Choreographer frame callbacks tied to VSYNC.
   Fixed by using Promise.resolve().then() (microtask) for zero-delay
   scheduling, which executes on the same event loop tick.
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