Skip to content

ref(core)!: Remove startIdleSpan from server exports - #23420

Open
Lms24 wants to merge 3 commits into
lms/ref-browser-treeshake-span-streamingfrom
lms/ref-remove-startIdleSpan-from-server
Open

ref(core)!: Remove startIdleSpan from server exports#23420
Lms24 wants to merge 3 commits into
lms/ref-browser-treeshake-span-streamingfrom
lms/ref-remove-startIdleSpan-from-server

Conversation

@Lms24

@Lms24 Lms24 commented Aug 13, 2026

Copy link
Copy Markdown
Member

The startIdleSpan API is exported from @sentry/core but is only used in browser SDKs. It should not be used anywhere else. Therefore, this PR removes the API from @sentry/core/server. It can still be imported from the shared top-level exports because these re-export everything. Something I think we should change but I currently don't have the time to look at in more depth.

@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 e82a7ec. Configure here.

Comment thread packages/core/src/tracing/idleSpan.ts
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.56 kB -5.75% -1.74 kB 🔽
@sentry/browser - with treeshaking flags 26.91 kB -5.48% -1.56 kB 🔽
@sentry/browser - with treeshaking flags tracing without tracing 26.81 kB - -
@sentry/browser (incl. Tracing) 48.54 kB -0.09% -39 B 🔽
@sentry/browser (incl. Tracing + Span Streaming) 48.56 kB -0.06% -25 B 🔽
@sentry/browser (incl. Tracing, Profiling) 51.44 kB -0.04% -19 B 🔽
@sentry/browser (incl. Tracing, Replay) 87.94 kB -0.05% -38 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.32 kB -0.06% -40 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 92.66 kB -0.06% -47 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 105.35 kB -0.05% -49 B 🔽
@sentry/browser (incl. Feedback) 45.8 kB -3.87% -1.84 kB 🔽
@sentry/browser (incl. sendFeedback) 33.36 kB -5.04% -1.77 kB 🔽
@sentry/browser (incl. FeedbackAsync) 38.45 kB -4.54% -1.82 kB 🔽
@sentry/browser (incl. Metrics) 29.51 kB -5.55% -1.73 kB 🔽
@sentry/browser (incl. Logs) 29.79 kB -5.49% -1.73 kB 🔽
@sentry/browser (incl. Metrics & Logs) 30.44 kB -5.32% -1.71 kB 🔽
@sentry/react 30.33 kB -5.49% -1.76 kB 🔽
@sentry/react (incl. Tracing) 50.78 kB +0.02% +10 B 🔺
@sentry/vue 35.38 kB +0.12% +40 B 🔺
@sentry/vue (incl. Tracing) 50.53 kB -0.03% -13 B 🔽
@sentry/svelte 28.58 kB -5.75% -1.74 kB 🔽
CDN Bundle 30.3 kB -4.13% -1.3 kB 🔽
CDN Bundle (incl. Tracing) 48.93 kB +0.07% +33 B 🔺
CDN Bundle (incl. Logs, Metrics) 32.52 kB -3.78% -1.28 kB 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) 50.84 kB +0.06% +28 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 72.89 kB -1.91% -1.41 kB 🔽
CDN Bundle (incl. Tracing, Replay) 86.49 kB +0.02% +15 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.34 kB +0.04% +29 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.19 kB -0.01% -1 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.14 kB +0.02% +14 B 🔺
CDN Bundle - uncompressed 89.88 kB -4.23% -3.96 kB 🔽
CDN Bundle (incl. Tracing) - uncompressed 146.79 kB +0.04% +47 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.18 kB -3.96% -3.96 kB 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.49 kB +0.04% +47 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.12 kB -1.73% -3.96 kB 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.06 kB +0.02% +47 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.73 kB +0.02% +47 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.75 kB +0.02% +47 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.42 kB +0.02% +47 B 🔺
@sentry/nextjs (client) 53.28 kB -0.03% -15 B 🔽
@sentry/sveltekit (client) 48.98 kB -0.04% -16 B 🔽
@sentry/core/server 64.48 kB -1.38% -897 B 🔽
@sentry/core/browser 51.78 kB +0.12% +58 B 🔺
@sentry/node 117.03 kB - -
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 81.43 kB -0.01% -1 B 🔽
@sentry/aws-serverless 90.92 kB - -
@sentry/cloudflare (withSentry) - minified 213.98 kB - -
@sentry/cloudflare (withSentry) 528.93 kB - -

View base workflow run

* An idle span is always the active span.
*/
export function startIdleSpan(startSpanOptions: StartSpanOptions, options: Partial<IdleSpanOptions> = {}): Span {
const client = getClient();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: The startIdleSpan function in core now unconditionally installs a browser-specific span streaming integration, which will cause issues if the function is called in a server environment.
Severity: MEDIUM

Suggested Fix

The startIdleSpan function should not unconditionally install the browser-specific integration. Instead, it should perform an environment check to ensure the correct integration is installed, or the responsibility for installing the appropriate integration should be moved to the environment-specific SDKs (browser/server) rather than being handled in shared core code.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/core/src/tracing/idleSpan.ts#L93

Potential issue: The `startIdleSpan` function, located in the shared
`packages/core/src/tracing/idleSpan.ts`, now unconditionally calls
`_INTERNAL_ensureBrowserSpanStreaming()`. This function proceeds to install a
browser-specific span streaming integration. Although `startIdleSpan` is intended for
browser environments, it remains accessible and exportable from the top-level
`@sentry/core` package. If a server-side SDK or a non-browser environment imports and
executes `startIdleSpan`, it will incorrectly install the browser integration. This
leads to a mismatch, as the browser integration depends on browser-specific APIs and
event handling mechanisms that are not present in a server environment, causing
incorrect behavior.

Did we get this right? 👍 / 👎 to inform future reviews.

@Lms24
Lms24 requested review from a team as code owners August 13, 2026 16:36
@Lms24
Lms24 requested review from chargome, logaretm, msonnb and s1gr1d and removed request for a team August 13, 2026 16:36
@Lms24
Lms24 force-pushed the lms/ref-remove-startIdleSpan-from-server branch from 9e30341 to b6e0cb0 Compare August 13, 2026 16:36
@Lms24
Lms24 force-pushed the lms/ref-remove-startIdleSpan-from-server branch from b6e0cb0 to 75ed06d Compare August 13, 2026 16:55
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.

2 participants