Skip to content

fix(ws): retry 5xx handshake refusals and honor Retry-After (1.6.2) - #23

Merged
odds-api-io merged 2 commits into
mainfrom
fix/ws-retry-transient-handshake
Nov 20, 2026
Merged

odds-api-io merged 2 commits into
mainfrom
fix/ws-retry-transient-handshake

Conversation

@odds-api-io

Copy link
Copy Markdown
Owner

With the ws package installed, a reconnect handshake refused with any HTTP status other than 429 was treated as fatal, so a 503 sent while the server restarts (with Retry-After: 2) stopped the feed for good.

  • 429 and 5xx handshake refusals are retried with the normal backoff; the delay is at least the Retry-After value. With ws, the status and headers are read from unexpected-response.
  • 400, 401, 403 and 426 stay fatal.
  • Network errors keep being retried.
  • After maxReconnectAttempts, the error names the last HTTP status.
  • The native WebSocket does not expose the handshake status, so a refused handshake there closes with 1006 and is already retried with backoff (no Retry-After).

Tests: fake-socket cases for 500/502/503/504, Retry-After, 403 via unexpected-response, give-up message and network errors, plus two tests against a local server using the real ws package (503 with Retry-After then success; 401 fatal). ws is added as a dev dependency for those.

Version 1.6.2 with changelog.

A refused reconnect handshake with HTTP 500/502/503/504 (for example the
503 the server sends while it restarts) stopped the helper for good.
These are now retried with backoff like 429, waiting at least as long as
the Retry-After header asks when the ws package is used. 400, 401, 403
and 426 stay fatal.

Release 1.6.2.
@odds-api-io
odds-api-io merged commit d3177ec into main Nov 20, 2026
4 checks passed
@odds-api-io
odds-api-io deleted the fix/ws-retry-transient-handshake branch November 20, 2026 16:47
odds-api-io added a commit that referenced this pull request Nov 21, 2026
)

A reconnect handshake refused with HTTP 500/502/503/504, such as the 503 the server sends while it restarts, no longer stops the WebSocket helper. These are retried with backoff and wait at least as long as Retry-After asks (with the ws package). 400, 401, 403 and 426 stay fatal.
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