Skip to content

fix(core): Do not count dropped errors in request sessions - #25632

Open
s1gr1d wants to merge 5 commits into
developfrom
sig/request-session-filtered-errors
Open

s1gr1d wants to merge 5 commits into
developfrom
sig/request-session-filtered-errors

Conversation

@s1gr1d

@s1gr1d s1gr1d commented Oct 21, 2026

Copy link
Copy Markdown
Member

Errors that ignoreErrors, beforeSend or an event processor drops no longer mark the request session as errored or crashed. Errors that sampleRate drops still count. This is the same rule that already applies to client sessions since #22671.

Before, ServerRuntimeClient set the request session status in captureException/captureEvent, before the event pipeline ran. Now the status is set at the same point in the pipeline as the client session update.

Event processing can finish after the response ends (e.g. async ContextLines reads). Because of this, the request session now waits for its pending error events before it is recorded. If client.flush() runs during that wait, the session is sent immediately. This is necessary because the flush sends the aggregate before it waits for event processing.

Fixes #25605

@s1gr1d
s1gr1d requested a review from a team as a code owner October 21, 2026 16:07
@s1gr1d

s1gr1d commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: c2007eb (PR test merge using develop at e1026aa)

Against: e1026aa (develop) · base run #63365

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.01 kB +0.09% +24 B 🔺
@sentry/browser - with treeshaking flags 28.15 kB +0.09% +24 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 28.05 kB +0.09% +24 B 🔺
@sentry/browser (incl. Tracing) 52.2 kB +0.06% +27 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 52.2 kB +0.06% +27 B 🔺
@sentry/browser (incl. Tracing, Profiling) 55.15 kB +0.05% +27 B 🔺
@sentry/browser (incl. Tracing, Replay) 91.98 kB +0.03% +20 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 80.88 kB +0.03% +24 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 96.71 kB +0.03% +20 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 109.65 kB +0.02% +21 B 🔺
@sentry/browser (incl. Feedback) 47.53 kB +0.06% +25 B 🔺
@sentry/browser (incl. sendFeedback) 35.08 kB +0.07% +24 B 🔺
@sentry/browser (incl. FeedbackAsync) 40.18 kB +0.06% +24 B 🔺
@sentry/browser (incl. Metrics) 31.03 kB +0.08% +22 B 🔺
@sentry/browser (incl. Logs) 31.3 kB +0.07% +21 B 🔺
@sentry/browser (incl. Metrics & Logs) 31.97 kB +0.08% +24 B 🔺
@sentry/react 31.84 kB +0.07% +22 B 🔺
@sentry/react (incl. Tracing) 54.53 kB +0.06% +32 B 🔺
@sentry/vue 38.17 kB +0.08% +27 B 🔺
@sentry/vue (incl. Tracing) 55.13 kB +0.05% +23 B 🔺
@sentry/svelte 30.03 kB +0.08% +24 B 🔺
@sentry/remix (Remix 3 client bundle) 57.22 kB +0.04% +21 B 🔺
CDN Bundle 31.77 kB +0.06% +16 B 🔺
CDN Bundle (incl. Tracing) 52.73 kB +0.04% +18 B 🔺
CDN Bundle (incl. Logs, Metrics) 33.97 kB +0.06% +19 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 54.68 kB +0.05% +24 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 74.94 kB +0.02% +14 B 🔺
CDN Bundle (incl. Tracing, Replay) 90.43 kB +0.03% +22 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92.36 kB +0.03% +24 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 96.57 kB +0.03% +25 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.52 kB +0.03% +23 B 🔺
CDN Bundle - uncompressed 93.58 kB +0.07% +65 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 156.43 kB +0.05% +65 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.13 kB +0.07% +65 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 162.4 kB +0.05% +65 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 230.34 kB +0.03% +65 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 276.77 kB +0.03% +65 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 282.73 kB +0.03% +65 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 290.47 kB +0.03% +65 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 296.42 kB +0.03% +65 B 🔺
@sentry/nextjs (client) 57.41 kB +0.05% +26 B 🔺
@sentry/sveltekit (client) 52.57 kB +0.04% +20 B 🔺
@sentry/core/server 42.02 kB +0.33% +136 B 🔺
@sentry/core/browser 13.81 kB - -
@sentry/node 153.34 kB +0.1% +142 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.58 kB - -
@sentry/node - without tracing 94.85 kB +0.15% +138 B 🔺
@sentry/node - without channel injection 133.93 kB +0.11% +134 B 🔺
@sentry/aws-serverless 103.01 kB +0.14% +137 B 🔺
@sentry/cloudflare (withSentry) - minified 194.02 kB +0.15% +284 B 🔺
@sentry/cloudflare (withSentry) 482.85 kB +0.2% +936 B 🔺
@sentry/nextjs/cloudflare (withSentry) - minified 214.67 kB +0.13% +272 B 🔺

View base workflow run

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e4c2c57. Configure here.


if (flushNow) {
flushPendingClientAggregates();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Flush-now skips existing aggregates

Medium Severity

When a request session settles after client.flush(), flushNow only sends if this call created the aggregate. Another request that records during that wait can already have opened a bucket, so this session is added and not sent. The in-flight flush then drains the transport without it, and a shutdown flush can drop the session.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e4c2c57. Configure here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think one way we could solve this is by adding something like an afterFlushProcessing client hook that the client emits in its flush method after determining clientFinished. This should allow us to get rid of the flushNow flag that only worked locally for this request

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sounds good!

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 1 not successful, 64 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E node-anthropic-send-to-sentry (latest) Test (optional) Failing after 24s Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E astro-7-static Test (optional) Successful in 48s Details
✅ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Successful in 53s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 49s Details
✅ CI: Optional E2E Tests / E2E angular (canary) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (canary) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 33s Details
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 48s Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-openai-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-14 (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (deno) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (canary, turbopack) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 4m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 26s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions-send-to-sentry (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 20s Details
✅ CI: Optional E2E Tests / E2E nextjs-orpc Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vue-3 (canary) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry-static Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 43s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 59s Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-3 (canary) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 25s Details
✅ CI: Optional E2E Tests / E2E nextjs-16-standalone (canary, turbopack) Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E node-anthropic-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 (tracer provider) Test (optional) Successful in 24s Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 34s Details
✅ CI: Optional E2E Tests / E2E node-openai-send-to-sentry (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 34s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 37s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (canary, webpack) Test (optional) Successful in 5m Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 36s Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-4 (canary) Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E angular (canary) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E supabase-nextjs Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 32s Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 27s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 26s Details
✅ CI: Optional E2E Tests / E2E nuxt-4-static (canary) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 56s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E node-eve (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 26s Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details

@Lms24 Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing this, I admittedly forgot about the server side part when we made the change in browser.

Took me a bit to understand the pendingRequests logic but I think it's fine and shouldn't hurt us or leak memory (that is assuming the isolationScope cleans up at which point the references to the pending errors should be gc'd).

I think we still should address the bugbot comment but otherwise, looks great!

The scenario sets `sessionFlushingDelayMS` on `httpIntegration`, which has no effect with `@sentry/bun`, so the session aggregate arrives after the test timeout.
A session that settled while `client.flush()` waited for event processing was only sent when it opened a new aggregate. If another request opened an aggregate during that wait, the session joined it and that flush did not send it.

Add an `afterFlushProcessing` client hook, which `flush()` emits after event processing and before the transport flush. Request session aggregates now also send on this hook.
@s1gr1d
s1gr1d requested review from Lms24 and isaacs October 23, 2026 14:28

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

None yet

Development

Successfully merging this pull request may close these issues.

Request sessions count errors dropped by ignoreErrors or beforeSend

2 participants