Fix unhandled rejection from session ping when network is unavailable #56

Merged
chrisp merged 1 commit from fix/session-ping-unhandled-rejection into main 2026-05-27 16:14:15 +00:00

1 commit

Author SHA1 Message Date
Chris Parsons
43660d16e9 Fix unhandled rejection from session ping when network is unavailable
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 1m36s
🚀 Deploy / ʦ TypeScript (pull_request) Successful in 1m21s
🚀 Deploy / 🔍 Lint (pull_request) Successful in 50s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
The 15-minute keep-alive interval in useDraftAuthRecovery called
authClient.getSession() with no try-catch. When the network is
unavailable (e.g. computer waking from sleep), better-fetch throws a
TypeError rather than returning an in-band error, producing an
unhandled promise rejection that was surfacing in Sentry.

Adds a try-catch that silently swallows network TypeErrors — real
session expiry (401) is still caught by the existing !session check
because better-fetch returns HTTP errors in-band as { data: null }.

Adds tests covering the three ping outcomes: network throw, null
session (expired), and valid session.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 09:08:52 -07:00