Files
photoreport/docs/errors.md
T
sparkandClaude Opus 5.5 64d52fc691
ci / rust (push) Successful in 15m6s
ci / typescript (push) Successful in 18m21s
Errors to errors.bitreport.pt from API, worker, app, desktop, sites and print agent
API and worker report error log lines, unhandled 5xx and crashes to the hub with the
photoreport ingest key (ERROR_REPORTING_TOKEN); browsers (app, desktop webview, sites),
Next server renders and the print agent send through POST /v1/client-errors so the key
stays on the server. Repeats folded, rate-limited. docs/errors.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HT6iXLYUUp9pJz5Kza9xCW
2026-10-14 19:32:54 +01:00

28 lines
2.0 KiB
Markdown

# Errors → errors.bitreport.pt
Every part of PhotoReport reports its errors to BitReport's error hub (errors.bitreport.pt, repo
`BitReport.pt/errors.bitreport.pt`), project slug `photoreport`, Gitea repo `BitReport.pt/photoreport`. Paperclip
reads the hub (`/v1/paperclip/recent-errors?project_slug=photoreport`) and works on them.
| Part | How | `component` |
|------|-----|-------------|
| API (pr-api) | error log lines, unhandled 5xx (method, route), crashes | `api` |
| Worker (pr-api, PM2) | error log lines, warnings that carry an error (a job that failed and is retried), crashes | `worker` |
| Web app | uncaught errors, unhandled rejections, React render errors → `POST /v1/client-errors` | `app` |
| Desktop (Tauri webview) | same as the web app | `desktop` |
| Public sites (browser) | uncaught errors, unhandled rejections → `/v1/client-errors` on the site's origin | `site` |
| Public sites (server render) | Next `onRequestError` → the API's `/v1/client-errors` | `site-server` |
| Print agent | crashes → its API's `/v1/client-errors` | `print-agent` |
Only the API holds the hub's key (`ERROR_REPORTING_TOKEN` in pr-api's `.env`, the ingest key of the
`photoreport` project on the hub); browsers and agents send to the API, which passes events on. Without the key
nothing is sent (development, tests). `ERROR_REPORTING_DISABLED=1` turns it off.
Each event carries `component`, `environment`, `release` (the deployed commit, `APP_VERSION`), file and line of the
first frame in our code, and the context logged with it. The same error (same component, message shape and place)
is sent once per 10 minutes, with how many times it happened since (`repeated_since_last_report`); browsers send
each error once per page load, at most ten a minute. `/v1/client-errors` is rate-limited (30 a minute per address).
Code: `apps/api/src/lib/reporter.ts` (a port of the hub's Node client), `apps/api/src/lib/clientErrors.ts`,
`apps/app/src/errorReporting.ts`, `apps/site/src/components/ErrorReporter.tsx`, `apps/site/src/instrumentation.ts`.