Skip to content

Auto-reconnect is unbounded and ignores server Goodbye/kick #59

Description

@ctoth

Summary

Auto-reconnect uses a flat 10s retry with no backoff, no cap, and no respect for a server-initiated goodbye, so a kicked or banned client reconnects forever.

Details

src/client.ts:171-179:

this.ws.onclose = () => {
  this.cleanupConnection();
  if (!this.intentionalDisconnect) {
    this.reconnectTimer = setTimeout(() => { this.connect(); }, 10000);
  }
};

intentionalDisconnect is only ever set by close() (line 285), i.e. a local user action. A server that closes the socket to kick or ban the user gets reconnected to 10 seconds later, indefinitely. There is no exponential backoff, no jitter, and no maximum attempt count.

GMCPCore.handleGoodbye (src/gmcp/Core.ts) only logs, so a Core.Goodbye from the server does not suppress the reconnect.

Fix direction

Add capped exponential backoff with jitter, and have handleGoodbye set a flag that suppresses auto-reconnect.

Verification

Read src/client.ts end to end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions