Skip to content

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

Closed

Description

@yannickmonney

Summary

GlitchTip issues tale 109 (task TALE-405) and tale 373 (TALE-355), both titled BackendApiError: The platform is not answering right now — a deployment may be rolling; retry with …, are browser events. So is tale 371 (TALE-353), titled BackendApiError: The platform’s database is not answering right now — it may be restarting; retry w….

The SPA reports, at error level, every request that fails while the platform restarts:

  • the edge's UPSTREAM_UNAVAILABLE (502, 503 or 504), while a deployment rolls or the app tier restarts;
  • the platform's 503 DATABASE_UNAVAILABLE, while its database restarts.

The backend treats both as operational events and reports neither. The observability page says "A database restart is not reported as an error", and backend/db/unavailable.ts says "an operational event, not a defect … none of them reports an error". The browser, however, sends one event for each write that fails in that window, and one for each list read that reaches its error state, from every open tab. One restart therefore opens one error event per failed request.

Everything the person sees during such an outage is right (see below). Only the reporting is wrong.

Where the message comes from (main a703a9598)

  1. The sentence is the edge's, not the platform's. It exists in one place: the proxy's handle_errors 502 503 504 → @machineDoor rule, which answers it for /api/*, /events and the other machine doors when the upstream refuses, is marked down or times out (Caddyfile L409–L413).
  2. BackendApiError is the browser's class. backendApiErrorFromBody reads the flat {error, code} envelope: the sentence becomes the message, UPSTREAM_UNAVAILABLE the code, and the status stays 502, 503 or 504 (api-client.ts L92–L120).
  3. It reaches GlitchTip through the console.
    • A failed write logs console.error('Mutation failed: …', error) (use-backend-mutation.ts L77), and a failed action logs its twin.
    • A list in its error state logs Error caught by boundary: through useErrorLogger.
    • captureConsoleIntegration({ levels: ['error'] }) turns each into captureException(error): logger console, mechanism auto.core.capture_console (router.tsx L99–L113).
  4. beforeSend keeps it. prepareSentryEvent drops a cancelled request, an extension's error, a 4xx refusal and a transport failure. Since fix(platform): report browser defects, not extension or refusal noise #3513, every 5xx still reports (sentry-normalize.ts L209–L217).

The two identical titles land as separate GlitchTip issues (109 and 373) presumably because GlitchTip groups by title and location, and each call site gives the thrown error a different stack. That last point is an inference: the imported cards carry only the title.

Local reproduction (inert, synthetic, nothing production)

Setup:

  • Edge: the repo's own services/proxy/Caddyfile, rendered by its own docker-entrypoint.sh, on Caddy 2.11.4 (the image's base is caddy:2.11-alpine). Only file paths and the compose DNS names were rewritten to loopback.
  • App tier and database: the real backend and the Vite app of each revision, behind that edge, on an isolated PostgreSQL 16.
  • Browser and errors: real Chromium. SENTRY_DSN pointed at a local sink.
  • Data: a synthetic organization, project and tasks per round. Backend egress went to a dead proxy.

How the outages were staged:

  • The edge's outage was a loopback relay standing in for backend-api:3005 that closes its listener, so the edge's dial is refused as it is mid-roll.
  • The database's was pg_ctl -m fast, the image's SIGINT stop.
  • The control was the relay answering the backend's own text 500.
Scenario main a703a9598 with the fix
Create task while the edge answers UPSTREAM_UNAVAILABLE One toast ("Something went wrong — try again…"), dialog open, title kept, no task created; Create succeeds once the edge answers again. 1 error event: BackendApiError: The platform is not answering right now — … (logger console). Same for the person. 0 events
Open the projects list while the edge answers UPSTREAM_UNAVAILABLE projects/overview tried 4 times (1 s, 2 s, 4 s apart), then the table's error state with Try again, never an empty list. 1 error event (same title, through the boundary logger). Same. 0 events
Cold page load while the edge answers UPSTREAM_UNAVAILABLE Skeleton until the edge answers, then the page, about 1 s later. 0 events. Same
Create task while the database restarts (DATABASE_UNAVAILABLE) One toast, dialog open, title kept; Create succeeds afterwards. 1 error event: BackendApiError: The platform’s database is not answering right now — … Same. 0 events
Control: the backend's own 500 One toast, title kept. 1 error event BackendApiError: Request failed with status 500 Still 1 event

In the database case the backend logged warnings only: 57P01 on the auth pool, pg-boss's one quiet line, /events backing off on 57P03, and the 503. The process stayed up and sent nothing.

Observation, not changed here: a list that reached its error state fills in by itself only when the /events stream reopens. That took 26–27 s after the edge answered again in a 21 s outage, because the reopen backs off exponentially, up to 60 s. Try again works at once.

Expected

These two answers are not reported from the browser either, consistent with the backend and the docs. The person still gets the toast or the list's error state. Every other 5xx keeps reporting: the backend's 500, a 502 the edge did not word, a dependency's 503 such as OBJECT_STORE_UNAVAILABLE, and either code at another status.

Related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions