Skip to content

fix(platform): stop reporting restart answers from the browser - #4033

Merged
yannickmonney merged 5 commits into
mainfrom
fix/browser-unreported-platform-restarts
Oct 1, 2026
Merged

yannickmonney merged 5 commits into
mainfrom
fix/browser-unreported-platform-restarts

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

The browser no longer reports, as an error, a request that failed while the platform restarted. This covers the edge's UPSTREAM_UNAVAILABLE (502, 503 or 504) during a deployment roll or restart, and the platform's 503 DATABASE_UNAVAILABLE while its database restarts. The backend already treats both as operational events and reports neither. The browser opened one error-level BackendApiError event for every failed write and failed list read in every open tab: GlitchTip tale 109 and 373 (TALE-405, TALE-355), and 371 (TALE-353). Every other 5xx still reports.

Closes #4032

What changed

  • app/lib/backend/platform-unavailable.ts (new): isPlatformUnavailable(error) is true only for a BackendApiError whose code and status are one of these two answers:
    • UPSTREAM_UNAVAILABLE at 502, 503 or 504, the edge's @machineDoor envelope;
    • DATABASE_UNAVAILABLE at 503, from databaseUnavailableResponse.
  • app/lib/sentry-normalize.ts: prepareSentryEvent, the app's beforeSend, drops such an event. It judges hint.originalException, as the refusal rule does, never the event's text.
  • Tests:
    • platform-unavailable.test.ts reads the real app door's answer while its database restarts (the real appErrorHandler on a 57P01), and the edge's envelope as the Caddyfile writes it. It also checks what must stay false: the backend's text 500, a 502 with no code, a dependency's 503 (OBJECT_STORE_UNAVAILABLE), and either code at another status.
    • sentry-normalize.test.ts has a new "an unavailable platform" block: drops at 502/503/504 and for the database, and keeps the 500, a codeless 502 and a text-only look-alike.
    • The existing "keeps a 5xx, even one carrying structured data" case used DATABASE_UNAVAILABLE as its example. It now uses OBJECT_STORE_UNAVAILABLE, so it still proves what it was written for.
  • Docs and manual layer:
    • observability-config.md (EN/DE/FR) lists the new exclusion; "Other server errors … are still reported".
    • The manual error-codes.md rows for both codes say the browser sends nothing.
    • The automation.md row names the new spec.
    • New box PERF-B8 covers a write and a list while the app tier is away. The performance suite goes to 19 boxes and the readme total up by one (1063 after merging main at c278e4ec1).

The person-facing behaviour is unchanged, and the reproduction below checks it. No edge, Ops or release change.

How I verified it

Real-browser reproduction. Inert and synthetic; nothing touched production.

  • Edge: the repo's own Caddyfile, rendered by its own docker-entrypoint.sh, on Caddy 2.11.4. Only file paths and compose names were rewritten to loopback.
  • App tier and database: the real backend and app of each revision behind it, and an isolated PostgreSQL 16.
  • Browser and errors: Chromium 1208, with SENTRY_DSN pointing at a local sink.
  • Outages:
    • the edge's: a loopback relay for backend-api:3005 closing its listener;
    • the database's: pg_ctl -m fast;
    • the control: the relay answering the backend's own text 500.
Scenario main a703a9598 this branch 7975a138e
Create task, edge outage 1 toast, title kept, no task; retry creates it. 1 error event BackendApiError: The platform is not answering right now — … same for the person; 0 events
Projects list opened, edge outage 4 attempts 1/2/4 s apart, error state with Try again (never empty); heals 27 s after the edge answers. 1 error event same (heals after 26 s); 0 events
Cold load, edge outage skeleton, page about 1 s after the edge answers; 0 events same
Create task, database fast shutdown 1 toast, title kept; retry creates it. 1 error event BackendApiError: The platform’s database is not answering right now — … same for the person; 0 events
Control: the backend's own 500 1 toast, title kept. 1 error event Request failed with status 500 1 error event, still reported

Negative control. With main's sentry-normalize.ts and the new tests, exactly the 4 new drop cases fail (UPSTREAM at 502/503/504, DATABASE at 503). All keep cases pass on both.

Local gates, all run on this branch (none replayed from a cache):

  • vitest --project server app/lib backend/error-reporting.test.ts: 34 files, 352 tests pass.
  • @tale/docs structural suite: 37 files, 222 tests pass.
  • Type-aware oxlint on the changed files is clean. A planted floating promise was caught, so the type-aware path was live.
  • Scoped tsc on the changed files and their import closure: 0 errors.
  • oxfmt, lint:manual, check-guide (performance suite), lint:links, lint:conflicts and opengrep (0 findings) are all clean.

Not run locally: the whole-platform tsc, the full unit/UI suites, knip and backend:integration. They need more than this sandbox's 4 GiB, and CI runs them. No backend or database file changed.

Coordination

Left open

  • A list that reached its error state fills in by itself only when the /events stream reopens, which backs off up to 60 s. That was 26–27 s after a 21 s outage here; Try again works at once. Not changed.
  • A failed write during a restart shows the generic "Something went wrong — try again…" toast, not a restart-specific sentence. Not changed.
  • Resolving GlitchTip tale 109, 371 and 373 needs a release carrying this change and GlitchTip access. Neither is part of this PR.

The browser reported every request that failed while the platform restarted
as an error-level BackendApiError: the edge's UPSTREAM_UNAVAILABLE (502/503/
504) while a deployment rolls, and the platform's 503 DATABASE_UNAVAILABLE
while its database restarts. The backend itself treats both as operational
events and reports neither, but each failed write or list read in each open
tab opened a GlitchTip event of its own (tale/tale #109, #373, #371).

prepareSentryEvent now drops a BackendApiError carrying one of these two
codes at the statuses it comes with (isPlatformUnavailable). Every other 5xx
still reports, including the backend's own 500 and a 502 the edge did not
word, and either code at another status. The person still sees one toast for
a failed write, with the draft kept, and the list's error state.

The observability docs (EN/DE/FR), the manual error-code and automation
registers, and a new PERF-B7 box say so.
#4031 adds PERF-B7 (a backend start during a database restart) to the same suite. Numbering this box PERF-B8 keeps the two IDs distinct whichever pull request lands first; the second to merge recounts the suite and readme totals.
…d-platform-restarts

# Conflicts:
#	services/platform/tests/manual/readme.md
The new observability bullet used a plain space before its colon; the French pages use U+00A0 there (write-translations CONVENTIONS).
The UPSTREAM_UNAVAILABLE row claimed every write keeps its draft; the reproduction observed it for Create task (PERF-B8). Other surfaces keep their own draft rules.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent review (TALE-416): approved at 708a8732e.

  • Exactness. Only UPSTREAM_UNAVAILABLE at 502/503/504 and DATABASE_UNAVAILABLE at 503 are dropped. The two codes have exactly two emitters (the Caddyfile's @machineDoor and databaseUnavailableResponse), and nothing on the client synthesizes them.
  • Real Chromium, with the shipped Sentry SDK initialized as router.tsx does it, fed real BackendApiErrors through the hooks' own console lines:
    • the four intended answers send 0 events;
    • each of these sends exactly 1 error event: the text 500, a codeless 502, OBJECT_STORE_UNAVAILABLE / MODEL_API_UNAVAILABLE at 503, either code at another status, a wrapped cause, a duck-typed object;
    • with main's sentry-normalize.ts, exactly the four drop cases fail.
  • CI on this head.
    • Platform test, test:ui, test:browser, typecheck and lint actually executed (cache miss).
    • @tale/docs:test replayed a run that executed the identical docs inputs at dba35a0a9 (37 files, 222 tests).
    • Playwright: 66 passed plus 1 pre-existing test.fixme. There is no diagnostics notice and no attempt artifact.
    • Backend integration was not owed: the scope job found no matching files.
    • Locally, lint:manual and check-guide pass.
  • Left open, not blocking:
    • a long app-tier outage now sends no browser event, which needs a product decision;
    • the backend also answers DATABASE_UNAVAILABLE for knowledge-pool failures (pre-existing), and those now reach no tracker;
    • the tests pin removals from the drop list, not additions.

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.

bug(platform): the browser reports the platform's restart answers as error events

1 participant