Skip to content

docs(ui): pin the scope of the socket's server-disconnect retry bound - #9582

Open
lstein wants to merge 1 commit into
invoke-ai:mainfrom
lstein:fix/9542-socket-reconnect-scope
Open

docs(ui): pin the scope of the socket's server-disconnect retry bound#9582
lstein wants to merge 1 commit into
invoke-ai:mainfrom
lstein:fix/9542-socket-reconnect-scope

Conversation

@lstein

@lstein lstein commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Resolves #9542 by option 1 from the issue: keep socket.io's own unbounded reconnection as the app's recovery path, and make the scope of the #9540 retry bound explicit in code and tests.

The five-attempt bound in useSocketIO governs server-initiated disconnects only. When one of those retries fails at the transport level (server restarting, proxy down), socket.io reports it as connect_error rather than disconnect, and socket.connect() has already re-armed the manager's reconnection, so the manager's default backoff (infinite attempts, 1s doubling to a 5s ceiling, ±50% jitter) takes over. Our counter never sees it.

That handoff is deliberate, and this PR says so where the next reader will look:

  • Rationale on MAX_SERVER_DISCONNECT_RECONNECTS: the server drops sockets for authorization changes and expects the client back, so reconnection: false or a reconnectionAttempts cap would strand the tab exactly when the server is briefly unreachable after such a change, and would hand the same dead end to every ordinary outage the manager rides out today. Also notes why the two drivers cannot race: a retry here fires once per server disconnect (which needs a connected socket), and Socket.connect() does not open the manager while it is between its own attempts.
  • Two tests pin it. A connect_error during a retry is left to the manager (the hook adds no second driver), and the socket is built with manager reconnection unbounded.

No behaviour changes. The thread's other conclusion stands too: raising only reconnectionDelayMax would not slow the manager's 1s/2s/4s opening steps, so a rate-limit, if ever wanted, needs its own specified policy and reproduction (the four-attempts-in-180ms burst has not reproduced with the lockfile's client versions).

QA Instructions

Frontend only. pnpm vitest run src/services/events/useSocketIO.test.tsx (12 pass). Each new test was checked against the mutation it guards: a connect_error handler that retries fails the first, and either reconnection: false or reconnectionAttempts: 5 fails the second, with nothing else affected. All five pnpm lint:* scripts pass.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog entry
  • Tests added / updated (if applicable)
  • Documentation added / updated (if applicable) — in-code rationale; no user-facing docs cover socket recovery

🤖 Generated with Claude Code

https://claude.ai/code/session_014Z8LWHPW4TfpNCtwUo5yr9

…invoke-ai#9542)

The five-attempt bound added in invoke-ai#9540 governs server-initiated disconnects
only. A retry that fails at the transport level surfaces as `connect_error`,
not `disconnect`, and `socket.connect()` re-arms the manager's reconnection,
so the manager's default unbounded backoff takes over from there.

That handoff is deliberate: the server drops sockets for authorization
changes and expects the client back, so `reconnection: false` or a
`reconnectionAttempts` cap would strand the tab exactly when the server is
briefly unreachable after such a change, and would hand the same dead end to
every ordinary outage the manager rides out today. Record that in the hook's
rationale and pin it with two tests: a `connect_error` during a retry is left
to the manager (no second driver), and the socket is built with manager
reconnection unbounded.

Closes invoke-ai#9542

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Z8LWHPW4TfpNCtwUo5yr9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.14.2 frontend PRs that change frontend files

Projects

Status: 6.14.2

Development

Successfully merging this pull request may close these issues.

socket.io Manager reconnection is unbounded after a server-disconnect retry fails at the transport level

2 participants