Skip to content

fix(core): Avoid blocking the process when calling flush on empty buffer#19062

Merged
Lms24 merged 12 commits intodevelopfrom
copilot/fix-issue-18996-bug
Jan 29, 2026
Merged

fix(core): Avoid blocking the process when calling flush on empty buffer#19062
Lms24 merged 12 commits intodevelopfrom
copilot/fix-issue-18996-bug

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

PR and description checked and updated by @Lms24

This PR fixes a bug when calling Sentry.flush() (or client.flush()) and there's no telemetry being processed by the SDK. While previously we'd wait for the passed-in timeout, we now exit early.

In addition, this also calls unref() on started timeouts for server SDKs so that pending timeouts started by the SDK don't block the process from exiting.

Copilot AI changed the title [WIP] Fix bug for issue 18996 in sentry-javascript Fix client.flush() blocking process exit due to non-unref'd timers Jan 28, 2026
Copilot AI requested a review from Lms24 January 28, 2026 16:05
@Lms24 Lms24 changed the title Fix client.flush() blocking process exit due to non-unref'd timers fix(core): Avoid blocking the process when calling flush on empty buffer Jan 28, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.35 kB +0.1% +24 B 🔺
@sentry/browser - with treeshaking flags 23.86 kB +0.12% +28 B 🔺
@sentry/browser (incl. Tracing) 42.17 kB +0.06% +24 B 🔺
@sentry/browser (incl. Tracing, Profiling) 46.81 kB +0.06% +24 B 🔺
@sentry/browser (incl. Tracing, Replay) 80.79 kB +0.03% +24 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.44 kB +0.04% +27 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 85.49 kB +0.03% +24 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 97.69 kB +0.03% +24 B 🔺
@sentry/browser (incl. Feedback) 42.07 kB +0.06% +24 B 🔺
@sentry/browser (incl. sendFeedback) 30.04 kB +0.08% +23 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.04 kB +0.07% +24 B 🔺
@sentry/browser (incl. Metrics) 26.46 kB +0.11% +29 B 🔺
@sentry/browser (incl. Logs) 26.61 kB +0.12% +30 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.27 kB +0.1% +26 B 🔺
@sentry/react 27.08 kB +0.1% +27 B 🔺
@sentry/react (incl. Tracing) 44.4 kB +0.07% +28 B 🔺
@sentry/vue 29.79 kB +0.09% +24 B 🔺
@sentry/vue (incl. Tracing) 43.96 kB +0.06% +23 B 🔺
@sentry/svelte 25.37 kB +0.1% +24 B 🔺
CDN Bundle 27.92 kB +0.08% +22 B 🔺
CDN Bundle (incl. Tracing) 42.96 kB +0.07% +27 B 🔺
CDN Bundle (incl. Logs, Metrics) 28.77 kB +0.09% +25 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 43.78 kB +0.07% +27 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 67.7 kB +0.04% +24 B 🔺
CDN Bundle (incl. Tracing, Replay) 79.69 kB +0.04% +25 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 80.56 kB +0.04% +26 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.14 kB +0.03% +23 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.07 kB +0.03% +25 B 🔺
CDN Bundle - uncompressed 81.69 kB +0.1% +75 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 127.23 kB +0.06% +75 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 84.52 kB +0.09% +75 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.06 kB +0.06% +75 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 207.91 kB +0.04% +75 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 243.83 kB +0.04% +75 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 246.65 kB +0.04% +75 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 256.63 kB +0.03% +75 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 259.44 kB +0.03% +75 B 🔺
@sentry/nextjs (client) 46.76 kB +0.07% +30 B 🔺
@sentry/sveltekit (client) 42.54 kB +0.06% +24 B 🔺
@sentry/node-core 52.1 kB +0.06% +27 B 🔺
@sentry/node 166.1 kB +0.02% +22 B 🔺
@sentry/node - without tracing 93.86 kB +0.03% +24 B 🔺
@sentry/aws-serverless 109.38 kB +0.03% +25 B 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 10,418 - 8,412 +24%
GET With Sentry 1,741 17% 1,612 +8%
GET With Sentry (error only) 6,980 67% 5,928 +18%
POST Baseline 1,044 - 1,171 -11%
POST With Sentry 541 52% 565 -4%
POST With Sentry (error only) 938 90% 1,048 -10%
MYSQL Baseline 3,732 - 3,243 +15%
MYSQL With Sentry 464 12% 469 -1%
MYSQL With Sentry (error only) 2,949 79% 2,646 +11%

View base workflow run

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

lgtm

Copilot AI and others added 9 commits January 29, 2026 18:03
…y exit

Co-authored-by: Lms24 <8420481+Lms24@users.noreply.github.com>
Co-authored-by: Lms24 <8420481+Lms24@users.noreply.github.com>
Co-authored-by: Charly Gomez <charly.gomez@sentry.io>
@Lms24 Lms24 force-pushed the copilot/fix-issue-18996-bug branch from 0ad6633 to 917fc69 Compare January 29, 2026 17:22
Copy link

@cursor cursor bot left a comment

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.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@Lms24 Lms24 merged commit c61baee into develop Jan 29, 2026
217 checks passed
@Lms24 Lms24 deleted the copilot/fix-issue-18996-bug branch January 29, 2026 18:26
Lms24 added a commit that referenced this pull request Feb 4, 2026
Quick follow-up from
#19062.

Closes #19083 (added automatically)
BYK added a commit to getsentry/cli that referenced this pull request Feb 16, 2026
…es (#249)

## Summary

Upgrade `@sentry/bun` and `@sentry/node` from 10.38.0 → 10.39.0 and
remove all custom patches/workarounds that are now fixed upstream.

## Changes

- **Removed `patches/@sentry%2Fcore@10.38.0.patch`** (92 lines) — Added
`.unref()` to timers in `setupWeightBasedFlushing`,
`_isClientDoneProcessing`, and `makePromiseBuffer` to prevent the CLI
from hanging on exit. Fixed upstream by
[#19062](getsentry/sentry-javascript#19062) and
[#19174](getsentry/sentry-javascript#19174).
- **Removed runtime context workaround in `src/lib/telemetry.ts`** (14
lines) — Manually overrode `options.runtime` after `Sentry.init()` to
report Bun instead of Node.js. Fixed upstream — `NodeClient` now uses
`options.runtime || { name: 'node', ... }` and `@sentry/bun` passes `{
name: 'bun', version: Bun.version }`. Tracked as
[#19269](getsentry/sentry-javascript#19269).
- **Updated `package.json`** — Bumped both SDK packages to `10.39.0` and
removed `@sentry/core` from `patchedDependencies`.

## Verification

- Verified all three upstream fixes by reading the 10.39.0 source code
and linked PRs
- `bun install`, typecheck, lint, and tests all pass cleanly
- No new test failures introduced (pre-existing ~95 failures on `main`
are unrelated)
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