Skip to content

fix(router): stop reporting browser network failures from route loaders - #846

Draft
posthog[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixrouter-stop-reporting-cancelled-063602
Draft

posthog[bot] wants to merge 2 commits into
mainfrom
posthog-self-driving/fixrouter-stop-reporting-cancelled-063602

Conversation

@posthog

@posthog posthog Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • Error tracking gets new noise issues when a user leaves a page while a route loader still fetches. The user sees nothing wrong.
  • The workspace loader calls a server function through ensureQueryData. When the browser cancels that request (for example on a full-page navigation), fetch rejects with a bare TypeError: Failed to fetch.
  • The router defaultOnCatch sends every loader error to PostHog, so this network TypeError becomes an error-tracking issue.

Origin

  • Error tracking: issue
  • First signal: 2026-09-28
  • Inbox report: open
  • Likely cause: 6b4e1da
  • Task started by: auto-start, after the report was rated P4 and ready to fix

Changes

  • defaultOnCatch now skips capture for TypeErrors that have a known browser network-failure message.
  • New helper isNetworkError in src/lib/network-error.ts holds the message list:
Engine Message
Chromium Failed to fetch
Firefox NetworkError when attempting to fetch resource.
Safari Load failed
  • The match is exact and needs a TypeError. Other TypeErrors (for example Cannot read properties of undefined) still go to error tracking.

Note

The error screen behavior does not change. A real network drop still shows AppErrorScreen. Only the report to error tracking stops.

Testing

  • vitest --project=node src/lib/network-error.test.ts: 2 tests pass.
  • vp check on the changed files: no format, lint, or type errors.

Agent context

  • I did not add a loader retry. fetchQuery does not retry by default. A retry does not help a request that the browser cancels during unload, and it makes a real outage show the error screen later. We can add it as a separate change if real network drops cause user complaints.
  • I put the filter in the router only, not in capturePostHogClientException, so the other capture paths keep their current behavior.

Closes #845


Created with PostHog Desktop from this inbox report.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

A route loader fetch that gets no response rejects with a bare TypeError, for example when the browser cancels the request during a full-page navigation. The router defaultOnCatch sent these to error tracking as new issues. Skip capture for known browser network-failure TypeErrors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: bcaca723-7de3-463d-a541-1453786b8141
@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 49218d5c-3653-4956-8ae1-69a606535508

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: bcaca723-7de3-463d-a541-1453786b8141
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit fe49390.

This branch has not been deployed

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

TypeError

0 participants