Stop reporting handled transient network errors to error tracking#40
Merged
Merged
Conversation
Transient `TypeError: Failed to fetch` network failures are already handled gracefully at their callsites (e.g. `fetchAllOpgaver` degrades to null), but they still surfaced as error-tracking issues because `entrypoints/content.tsx` monkeypatches `console.error` and `unhandledrejection` to forward everything into `captureException`. - Downgrade the `fetchAllOpgaver` failure log from `console.error` to `console.warn` so the handled failure no longer flows through the capture path. - Add an `isIgnorableNetworkError` guard in the catch-all `unhandledrejection` and `console.error` forwarders that drops generic transient network failures (`Failed to fetch` / `NetworkError when attempting to fetch resource.` / `Load failed`). Explicit `captureException()` calls elsewhere are untouched, so real failures still get reported. Generated-By: PostHog Code Task-Id: 68411aaa-acab-406d-b78b-0c287537f8ca
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR reduces PostHog error-tracking noise by preventing expected transient network failures (e.g. generic “Failed to fetch” across browsers) from being forwarded via the global unhandledrejection / console.error capture paths, while leaving intentional captureException() calls elsewhere unchanged.
Changes:
- Add an
isIgnorableNetworkErrorfilter and apply it to the globalunhandledrejectionforwarding andconsole.errormonkeypatch inentrypoints/content.tsx. - Downgrade
fetchAllOpgaver()’s transient failure log fromconsole.errortoconsole.warnto avoid generating error-tracking issues for handled failures.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| entrypoints/content.tsx | Adds transient-network-error filtering to global error forwarding and console error capture to avoid reporting handled fetch blips. |
| components/OpgaverPage.tsx | Changes the handled fetch-all failure log to console.warn to avoid being ingested by the global console.error forwarder. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+716
to
+720
| const joined = args.map(String).join(' '); | ||
| if ( | ||
| _blConsoleErrorCaptures < MAX_CONSOLE_ERROR_REPORTS && | ||
| !isIgnorableNetworkError(joined) && | ||
| !args.some(isIgnorableNetworkError) |
Comment on lines
+456
to
+458
| // Transient network failures here are expected and handled — we degrade to | ||
| // an empty list. Use console.warn so the global console.error capture in | ||
| // entrypoints/content.tsx doesn't report this as an error-tracking issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Transient
TypeError: Failed to fetchnetwork failures were showing up as error-tracking issues even though the extension already handles them gracefully. They leaked in becauseentrypoints/content.tsxmonkeypatchesconsole.errorandunhandledrejectionto forward everything intocaptureException— so an already-handled, expected network blip became a logged "issue" that buries genuine errors and burns free-tier quota.fetchAllOpgaverfailure log fromconsole.errortoconsole.warn(it already returnsnulland degrades cleanly).isIgnorableNetworkErrorguard to the catch-allunhandledrejectionandconsole.errorforwarders that drops generic transient network failures (Failed to fetch, Firefox'sNetworkError when attempting to fetch resource., Safari'sLoad failed). ExplicitcaptureException()calls elsewhere are untouched, so real failures still get reported.Why
The team was getting error-tracking noise from two issues (
TypeError: Failed to fetchand... Failed to fetch all opgaver: TypeError: Failed to fetch) that aren't real bugs — the features degrade cleanly and no user sees breakage. This keeps the error-tracking signal clean without hiding genuine failures.Created with PostHog Code from an inbox report.