Title: fix(realtime): end a failed socket-token attempt promptly and honor Retry-After by waleedlatif1 · Pull Request #8952 · simstudioai/sim · GitHub
Open Graph Title: fix(realtime): end a failed socket-token attempt promptly and honor Retry-After by waleedlatif1 · Pull Request #8952 · simstudioai/sim
X Title: fix(realtime): end a failed socket-token attempt promptly and honor Retry-After by waleedlatif1 · Pull Request #8952 · simstudioai/sim
Description: Summary When the realtime socket's auth callback can't get a token from /api/auth/socket-token (a 429 from its 30/min per-IP limit, a network error, or a 5xx), it never called cb. socket.io-client 4.8.1 sends CONNECT only from inside cb (socket.js:407-423), and the client's own 10s timeout is cleared once the transport opens (manager.js:135-170). So the attempt sat open until the realtime server's default 45s connect timeout, and users saw "Reconnecting…" the whole time. Retry-After was ignored. Just ending the attempt early isn't enough. The Manager resets its backoff on every transport open (manager.js:306, 361-365), so it would retry about once a second forever. The fix, for any failure other than 401: Disconnect the socket and clear the connection state the same way the disconnect handler does. Without that, a reconnect followed by an auth failure would keep showing "connected". Reconnect after backoffWithJitter (1s growing to 30s, the existing auth-retry constants). When the server sent Retry-After (parsed with parseRetryAfter, capped at 5 min because the route's bucket refills over 60s), wait at least that long, plus up to 20% jitter so tabs behind one IP don't retry in the same second. Reuse the provider's existing retry timer. If the provider has unmounted, signed out or switched workspace, the !active guard means nothing gets scheduled. The attempt counter resets on connect. The 401 path (session gone, passes a null token, goes terminal) is unchanged. No server or rate-limit changes. Effect: "Reconnecting…" appears after the existing 2s anti-flicker delay instead of about 45s, and the socket reconnects as soon as the backoff or Retry-After allows. During a long token-route outage, each tab retries about every 30s, compared with about every 46s before. Verified against a real Socket.IO server with a script: the old code hangs; the new code ends the attempt promptly, waits the delay, then connects; a 401 still produces connect_error with active=false. An adversarial review checked re-entrancy, timer races, unmount and sign-out, and backoff resets. Its two findings, the stale isConnected and the jitter, are included here. Test plan CI type-check and lint e2e (mobile, *): the socket-token mint check still passes
Open Graph Description: Summary When the realtime socket's auth callback can't get a token from /api/auth/socket-token (a 429 from its 30/min per-IP limit, a network error, or a 5xx), it never called cb. socket.io...
X Description: Summary When the realtime socket's auth callback can't get a token from /api/auth/socket-token (a 429 from its 30/min per-IP limit, a network error, or a 5xx), it never called cb. s...
Opengraph URL: https://github.com/simstudioai/sim/pull/8952
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:6cb3b0e7-9887-5245-87b2-59548ed1ce79 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E3C4:3B3600:99BB9A:D3813E:6AFB4C0B |
| html-safe-nonce | 3800a08fd2e19be61ec54f793ce5af3be11834d41b122e6899ddae44e587a8a6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0M0OjNCMzYwMDo5OUJCOUE6RDM4MTNFOjZBRkI0QzBCIiwidmlzaXRvcl9pZCI6IjUyNDkzNjUxMzE4Mjg4NzQyNTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2b78b645fa8ce0c001add410f10812e658053389bc3905eedfd57a9e042ee4bf |
| hovercard-subject-tag | pull_request:4837465359 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/8952/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary When the realtime socket's auth callback can't get a token from /api/auth/socket-token (a 429 from its 30/min per-IP limit, a network error, or a 5xx), it never called cb. socket.io... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | acf7616d06cc051644705b379878c9bb13dc5e70ecf4ffd9b34140f8ac01d7e1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 26504db649b58525278f77a52b80ba5f10d5f4de |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width