Repository navigation
projector: answer unhandled route errors with a JSON 500 - #10904
Conversation
handleRequest now wraps the router in an error boundary. A store or
database failure a route does not handle itself is logged and answered
as {error: "internal_error", message} with a JSON content-type,
instead of escaping to Bun's default non-JSON 500.
Fixes #10540
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 57 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Before: when a projector route hit a store or database error it did not handle itself (for example SQLITE_BUSY on
/items,/comments,/linksor/hot), the exception escapedhandleRequestand Bun answered with its default non-JSON 500, so callers that parse JSON failed with a confusing parse error.After: every unhandled route error is logged as
projector: <METHOD> <path> failed: <message>and answered as a 500 with a JSON body{"error": "internal_error", "message": "..."}. Routes that already return their own status (400, 404, 409 and so on) are unchanged.How: the existing router became a private
routeRequest, and the exportedhandleRequestwraps it in a try/catch. The reconcile route'sfinallystill runs inside the router. New testtest/error-boundary.test.tsdrives the read routes with a client whose every statement throws.Testing:
bun installcan't fetch packages in this environment, so I ran the new test with@libsql/clientstubbed bymock.module. It passes against this branch (2 pass) and fails against main (the read-route case gets a non-JSON response), as expected. CI will run it with the real dependency.Fixes #10540
Generated by Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.