Skip to content

fix(sentry): stop reporting browser AbortError noise - #931

Merged
kody-bot merged 3 commits into
mainfrom
cursor/sentry-triage-7632135877-6bb0
Jul 25, 2026
Merged

kody-bot merged 3 commits into
mainfrom
cursor/sentry-triage-7632135877-6bb0

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Sentry KODY-CLOUDFLARE-23 reported a single browser AbortError: The user aborted a request. on /oauth/authorize via auto.browser.global_handlers.onunhandledrejection (Edge 150, no stack frames, DOMException.code=20).

That is expected Chromium/Edge behavior when an in-flight fetch is aborted (superseded SPA navigation, user leaving the page, etc.). It is not an actionable product defect, and without a client filter it will keep reopening issues whenever users abort requests.

Change

  • Add a narrow browser beforeSend filter (filterBrowserAbortSentryEvent) that drops AbortError-named exceptions and exact well-known abort message strings (AbortError: The user aborted a request., The operation was aborted., etc.). Timeout wording is intentionally not matched.
  • Skip AbortError in captureClientException as a belt-and-suspenders path.
  • Unit tests cover the KODY-CLOUDFLARE-23 signature and ensure unrelated client errors (e.g. Navigation API TypeError) and timeout abort wording still report.

Worker-side sentry-options.ts cannot help here: browser envelopes are forwarded by /sentry-tunnel without going through Worker beforeSend.

Outcome

filtered — ship the filter, then mark the Sentry issue ignored once deployed.

Siblings (KODY-CLOUDFLARE-17 Navigation API, sandbox timeout, MCP validation) do not share this root cause and are left alone.

System recap — composes existing primitives (low risk)

Mode: recap · Base: main @ c1687e26 · Head: latest on branch

Classification: composes — no primitives added or changed; wires a narrow
beforeSend filter into the existing browser Sentry client.

Primitives touched

Primitive Group Impact
app-ui surfaces composes — browser Sentry beforeSend drops AbortError noise

System map

Browser AbortErrors are dropped in the client SDK before the envelope reaches the same-origin tunnel.

Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).

flowchart LR
	appUi["app-ui<br/>Browser app (Remix 3)"]:::touched
	sentryTunnel["sentry-tunnel<br/>Same-origin envelope forward"]:::untouched
	appUi -->|"beforeSend drops AbortError; other events still tunnel"| sentryTunnel
	classDef touched fill:#1a7f37,color:#fff
	classDef extended fill:#9a6700,color:#fff
	classDef added fill:#cf222e,color:#fff
	classDef untouched fill:#57606a,color:#fff
Loading

Before / after

Case Before After
AbortError: The user aborted a request. unhandledrejection Opens/regresses Sentry issue Dropped in client beforeSend
Unrelated client TypeError / app bugs Reported Still reported
Timeout abort wording Reported Still reported
Open in Web Open in Cursor 

Summary by CodeRabbit

  • Bug Fixes
    • Reduced Sentry noise by filtering expected browser abort/navigation-related errors before they’re sent.
    • Prevented known browser abort exceptions from being reported, while leaving unrelated errors untouched.
    • Improved abort detection across common browser error message variants and error shapes, including Cloudflare’s abort signature.
  • Tests
    • Added coverage for abort message variants, abort detection from different error forms (including AbortError), and validation that non-abort events remain unchanged.

Client unhandledrejection of AbortError (user navigated away / superseded
SPA fetch) is expected and not actionable. Filter it in browser beforeSend
so KODY-CLOUDFLARE-23 and siblings stop opening Sentry issues.
@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Browser abort detection utilities and tests were added, then integrated into Sentry initialization and client exception capture to filter abort-related events and exceptions.

Changes

Browser abort filtering

Layer / File(s) Summary
Abort detection and filtering
packages/worker/client/sentry-browser-filters.ts, packages/worker/client/sentry-browser-filters.node.test.ts
Defines typed Sentry event shapes, matches known abort messages and AbortError exceptions, filters matching events, and tests abort and non-abort cases.
Sentry capture integration
packages/worker/client/sentry-client.ts
Adds a beforeSend filter for Sentry events and skips direct exception capture for browser abort errors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SentryClient
  participant Sentry
  participant beforeSend
  participant AbortFilter
  SentryClient->>Sentry: initialize with beforeSend
  Sentry->>beforeSend: send event and original exception
  beforeSend->>AbortFilter: filterBrowserAbortSentryEvent(event, originalException)
  AbortFilter-->>beforeSend: null or unchanged event
  beforeSend-->>Sentry: return filtered event
Loading

Possibly related PRs

  • kentcdodds/kody#909: Both changes update browser Sentry initialization and client exception capture wiring.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: browser-side Sentry filtering for AbortError noise.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/sentry-triage-7632135877-6bb0

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.

@kody-bot
kody-bot marked this pull request as ready for review July 25, 2026 04:40
@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-931.kody-a99.workers.dev

Worker: kody-pr-931
D1: kody-pr-931-db
KV: kody-pr-931-oauth-kv

Mocks:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/worker/client/sentry-browser-filters.ts`:
- Around line 30-35: Restrict isBrowserAbortErrorMessage to exact known
abort-message variants instead of broadly matching any “AbortError:” prefix,
while preserving the existing exact strings. In
packages/worker/client/sentry-browser-filters.ts lines 30-35, replace the
startsWith check with explicit allowed variants; in
packages/worker/client/sentry-browser-filters.node.test.ts lines 9-23, add an
assertion that “AbortError: The operation was aborted due to timeout.” returns
false.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ae0fa542-106d-4695-85f2-f15c75d1a535

📥 Commits

Reviewing files that changed from the base of the PR and between c1687e2 and f6caffb.

📒 Files selected for processing (3)
  • packages/worker/client/sentry-browser-filters.node.test.ts
  • packages/worker/client/sentry-browser-filters.ts
  • packages/worker/client/sentry-client.ts

Address review feedback: drop the AbortError: prefix catch-all so timeout
wording is not filtered; keep exact Chromium/Firefox abort texts only.
Add the CodeRabbit regression for prefixed timeout wording, and remove the
bare "aborted" message match which is broader than needed (name checks cover
DOMException AbortError).
@kody-bot
kody-bot merged commit 0bfcec4 into main Jul 25, 2026
5 checks passed
@kody-bot
kody-bot deleted the cursor/sentry-triage-7632135877-6bb0 branch July 25, 2026 05:01
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.

3 participants