Repository navigation
Conversation
size-limit report 📦Compared: d3d2c2d (PR test merge using develop at 2007cec) Against: 2007cec (develop) · base run #68738 ✅ Baseline matches: this diff contains only this PR's changes.
|
|
One or more gzipped bundles increased by more than 500 bytes. If this increase is intentional, add the Accept Bundlesize Increase label to this PR to rerun and accept the check. |
Optional E2E testsSome optional checks were not successful. They do not block the merge. 1 not successful, 64 successful. See the run.
Successful checks
|
This comment was marked as resolved.
This comment was marked as resolved.
Split _processEvent into steps in the order of the client spec: roll the sample rate, run the filters (_applyFilters: event processors and the beforeSend callbacks), update the sessions (_updateSessions), and send. A sampled-out error goes through _countSampledOutError, which counts it in sessions if the filters keep it. No behavior change. The next change to which errors count in sessions can then override these steps instead of copying them. Refs #25605
Request sessions counted an error at capture time, before ignoreErrors, event processors and beforeSend ran. So errors that the user chose to drop still lowered the crash-free rate. Errors now count after beforeSend, as the client spec requires. Sampling and Dedupe only save quota, so an error that they drop still counts if the filters keep it. On the server, such an error runs the filters outside of the promise buffer, with its own limit, so it never pushes a real error out. Dedupe ignores sampled-out errors, so a repeated error is no longer dropped every time with a low sampleRate. Fixes #25605
82e3cd4 to
ab88166
Compare
This comment was marked as duplicate.
This comment was marked as duplicate.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ab88166. Configure here.
Only ServerRuntimeClient moves never-sent errors out of the promise buffer. In the browser a burst with async event processors can still overflow it, but one user rarely fills it, so the browser keeps the develop behavior to save bundle size.
Say why the browser keeps sampled-out errors in the promise buffer, why only exception events get the overflow hint, what the side lane limit trades off, why a marked duplicate rejects at once, and why the side lane increments _numProcessing.
## What `_processEvent` now reads in the order of the [client spec event pipeline](https://develop.sentry.dev/sdk/foundations/client/#event-pipeline). Each step is a function: `_applyFilters` (event processors and `beforeSend*`), `_updateSessions`, and `_countSampledOutError` for errors that sampling drops. No test changed. <table><tr><th>Before</th><th>After</th></tr><tr><td height=500 width=500> ```mermaid flowchart TD P["_processEvent<br/>(one long promise chain:<br/>sampling, _prepareEvent, beforeSend,<br/>session update, sampling drop, send)"] ``` </td><td height=500 width=500> ```mermaid flowchart TD S0{"rollSampleRate:<br/>sampled out?"} -- "no" --> S1["_applyFilters<br/>event processors + beforeSend*"] S1 --> S2["_updateSessions"] S2 --> S3["sendEvent"] S0 -- "yes" --> C["_countSampledOutError"] C -- "session can change" --> C1["_applyFilters"] --> C2["_updateSessions"] --> D["drop: sample_rate"] C -- "no session can change" --> D ``` </td></tr></table> ## Why The next PR (#26819) changes which errors count in sessions (#25605). With one function for each step, the server client can override a step there, and the fix does not copy the `beforeSend` and outcome logic. One small difference: `_updateSessions` reads the session when processing ends, not when the error is captured. It only matters if a new session starts while an event is processed, and it was the behavior before #25751. Refs #25605
…n-dropped-errors # Conflicts: # packages/core/src/client.ts # packages/core/src/server-runtime-client.ts # packages/core/test/lib/server-runtime-client.test.ts
|
@sentry-junior review |
There was a problem hiding this comment.
For the human reviewer
- Is it OK that
beforeSendand event processors now run for errors that are never sent (sampled out, or a duplicate once per request)? User callbacks with side effects or cost get more calls. - On the server, an error that overflows the promise buffer now counts in the request session without filters, so
ignoreErrorsmatches still count in that case. Is that the trade-off you want?
With attachStacktrace, eventFromMessage adds exception values to a message event, so the request session counted it as an error. The sessions spec says that captureMessage events must not count. eventFromMessage now flags these events, and ServerRuntimeClient skips them.
Replace a fixed 20 ms sleep with fake timers that advance exactly the delay of the async beforeSend. Use denoHttpIntegration in the sampled-errors session suite when httpIntegration does not exist, as the shared sessions suite does.
|
@sentry-junior review |
…equest-session-dropped-errors

Supersedes #25632
What
Errors that
ignoreErrors, an event processor orbeforeSenddrop no longer count in request sessions. Sampled-out and deduplicated errors still count if the filters keep them.Part 3 of 3 for #25605. Stacked on #27138 (Dedupe ignores errors that are never sent) and #27139 (request sessions wait for their errors).
Why
The client spec puts the session update after
beforeSendand before sampling. Request sessions counted errors at capture time, so dropped errors lowered the crash-free rate.beforeSendthat drops health checks still works for duplicates.queue_overflow. An error that is itself dropped withqueue_overflowstill counts, without the filters, because they could not run.The never-sent path is in
ServerRuntimeClientonly. In the browser, sampled-out errors still run the filters inside the promise buffer, as before. A burst of errors with an asyncbeforeSendor event processor can still overflow it there. But one user rarely fills the buffer, while a server gets the errors of all its requests. Moving the browser to the side lane too would cost about +220 B gzip, so the browser keeps the current behavior.The cost:
beforeSendnow also runs for errors that are not sent, once per request for a duplicate. With 1000 failing requests, it runs 1000 times instead of 3. The Python SDK does the same. More details are in this comment.flowchart TD CAP["captureException"] --> RS["Mark request session errored<br/>(before any filter: bug #25605)"] RS --> SMP{"Sampled out?"} SMP -- "yes, scope session cannot change" --> D1["Drop: sample_rate"] SMP -- "no, or scope session can change" --> P subgraph DB["Delivery buffer (64 slots)"] P["Event processors<br/>EventFilters, Dedupe, ContextLines, ..."] --> BS{"beforeSend"} BS -- "keeps" --> US["Update scope session"] US --> SMP2{"Sampled out?"} SMP2 -- "no" --> SEND["Send"] end P -- "a filter or Dedupe drops" --> D2["Drop: event_processor"] BS -- "drops" --> D3["Drop: before_send"] SMP2 -- "yes" --> D4["Drop: sample_rate"] classDef counts fill:#d4f4dd,stroke:#2e7d32 classDef nocount fill:#eeeeee,stroke:#757575 class RS,US counts class D1,D2,D3 nocountflowchart TD CAP["captureException"] --> SMP{"rollSampleRate:<br/>sampled out?"} SMP -- "yes" --> CS{"_countSampledOutError:<br/>can a session change?"} CS -- "no" --> D1["Drop: sample_rate"] CS -- "yes" --> F2 SMP -- "no" --> F1 subgraph DB["Delivery buffer (64 slots): errors that can be sent"] F1["_applyFilters<br/>event processors (Dedupe compares), beforeSend"] --> U1["_updateSessions<br/>scope + request"] U1 --> SEND["sendEvent"] end F1 -- "a filter drops" --> D2["Drop: event_processor / before_send"] F1 -- "duplicate, same request and handled" --> D3["Drop: event_processor<br/>(as before)"] F1 -- "duplicate, other request or unhandled,<br/>a session can change" --> F2 subgraph SB["_countWithoutSlot (own limit of 64)"] F2["_applyFilters<br/>(Dedupe ignores sampled-out errors)"] --> U2["_updateSessions"] end U2 --> D4["Drop: sample_rate / event_processor"] F2 -- "a filter drops" --> D2 classDef counts fill:#d4f4dd,stroke:#2e7d32 classDef nocount fill:#eeeeee,stroke:#757575 class U1,U2 counts class D1,D2,D3 nocountFixes #25605