Skip to content

fix(web): stop re-surfacing handled transient errors as exceptions#2194

Merged
tyler-dane merged 1 commit into
mainfrom
posthog-code/quiet-transient-error-noise
Jul 19, 2026
Merged

fix(web): stop re-surfacing handled transient errors as exceptions#2194
tyler-dane merged 1 commit into
mainfrom
posthog-code/quiet-transient-error-noise

Conversation

@posthog

@posthog posthog Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Three error-tracking issues were expected transient failures leaking in as noise from one staging user:

  • TypeError: Failed to fetch — a dropped connection during the SuperTokens session check, console.error'd in SessionProvider.checkIfSessionExists.
  • 502 PROVIDER_FAILURE (x2) — Google rejecting an event write; a retryable mutation error console.error'd in handleError.

Both surfaced as captured exceptions only because PostHog's capture_console_errors turned deliberate, user-facing error handling (toast + local console.error) into exception capture. In this project every captured exception reports as generic/handled:false, and the retryable 502 — which React Query already catches, so it can only reach PostHog via a console.error — confirms that console-capture is the vector.

Changes:

  • Set capture_console_errors: false in CompassProvider. Handled errors the app deliberately logs no longer double as new issues; genuinely uncaught errors and promise rejections are still captured by the other two handlers.
  • In handleError, treat a retryable, backend-authored mutation error (502 PROVIDER_FAILURE) as the expected transient failure it is: show the retry toast and skip console.error. This also replaces the raw "Request failed with status 502" toast with a friendly message.

Why: every network blip or Google provider hiccup was spawning a fresh "new issue" alert that looked like a real regression but wasn't, costing ongoing triage. Staging-only, negligible volume, but it recurs on every such failure — this preserves error-tracking signal-to-noise.

Simplicity

Two small, targeted changes in the files the noise originates from — one config flag plus one guard clause. No new abstractions.

Automated validation

Not run (config + error-handling change with no user-facing flow to reproduce beyond the unit-tested branch).

Independent review

N/A.

Test plan

  • bun test --cwd packages/web src/common/utils/event/event.util.test.ts — 8 pass (incl. new "does not log a retryable, backend-authored mutation failure").
  • bun test --cwd packages/web src/api/util/api.util.test.ts — 20 pass.
  • bunx typescript@7.0.2 -p packages/web/tsconfig.app.json --noEmit — clean.
  • bunx typescript@7.0.2 -p packages/web/tsconfig.test.json --noEmit — clean.
  • biome check on the three changed files — clean.

Created with PostHog Code from this inbox report.

Expected transient failures were leaking into error tracking as fresh
"new issue" alerts even though the app already handles them:

- A network blip during the SuperTokens session check is console.error'd
  in SessionProvider ("Failed to fetch").
- A retryable 502 PROVIDER_FAILURE (Google rejecting a write) is
  console.error'd in handleError.

Both surfaced as captured exceptions only because capture_console_errors
turned deliberate, user-facing error handling into exception capture.

- Turn off capture_console_errors so handled errors don't double as
  exceptions; unhandled errors/rejections are still captured.
- In handleError, treat a retryable backend-authored mutation error as an
  expected transient failure: show the toast, skip console.error (also
  replaces the raw "Request failed with status 502" toast with a friendly
  message).

Generated-By: PostHog Code
Task-Id: 74de4a8f-2e3d-47de-bfce-1685feaf014b
@tyler-dane
tyler-dane marked this pull request as ready for review July 19, 2026 03:25
@tyler-dane
tyler-dane merged commit be89bac into main Jul 19, 2026
16 checks passed
@tyler-dane
tyler-dane deleted the posthog-code/quiet-transient-error-noise branch July 19, 2026 03:25
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