Skip to content

fix: a 429 from mail.tm no longer crashes the inbox server - #3

Merged
brentc22 merged 2 commits into
mainfrom
fix/rate-limit-crash
Oct 5, 2026
Merged

brentc22 merged 2 commits into
mainfrom
fix/rate-limit-crash

Conversation

@brentc22

@brentc22 brentc22 commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Two routes returned withToken(...) without await inside the handler's try/catch, so a 429 from mail.tm skipped the catch, became an unhandled rejection and killed the server (the Mac app showed "The inbox server stopped").
  • The async request handler is now wrapped once: any error that escapes a route answers 500 instead of crashing or hanging.
  • 429s are retried in a shared fetchMailTm helper (also used for attachments): Retry-After when given, jittered backoff otherwise, and an immediate give-up when Retry-After exceeds 10s.
  • 429 reaches the browser as 429 instead of 500.

Test plan

  • npm test — 48/48, incl. new test/ratelimit.test.js (fails/hangs against the old code)
  • Rebuilt and installed the Mac app, server starts
  • Watch for a real 429 from mail.tm in daily use

Not addressed: throttling requests to mail.tm up front (~8 req/s), and the "all" view still shows a rate-limited mailbox as empty.

🤖 Generated with Claude Code

brentc22 and others added 2 commits October 5, 2026 09:55
Two handlers returned withToken(...) without await inside the request
try/catch, so a rejection skipped the catch and became an unhandled
rejection that killed the process. Now awaited, 429s are retried with
Retry-After/backoff, passed to the browser as 429, and the ui command
logs any stray rejection instead of exiting.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Review follow-up. The async request handler is now wrapped once, so an
error that escapes any route answers 500 instead of killing the server
or hanging the request; the process-wide unhandledRejection logger is
gone. 429 retries live in a shared fetchMailTm helper, also used by the
attachment download, with jittered backoff, and give up at once when
Retry-After is longer than the cap.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@brentc22
brentc22 merged commit ef98b7d into main Oct 5, 2026
5 checks passed
@brentc22
brentc22 deleted the fix/rate-limit-crash branch October 5, 2026 08:32
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