Skip to content

fix(browser): Preserve empty stacks in continuous profiles - #25764

Merged
msonnb merged 2 commits into
developfrom
ms/browser-profiling-idle-stacks
Oct 28, 2026
Merged

msonnb merged 2 commits into
developfrom
ms/browser-profiling-idle-stacks

Conversation

@msonnb

@msonnb msonnb commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

This fixes a bug where we fell back to stack ID 0 for profiling samples that don't have an associated stack (i.e. are idle). Stack ID 0 is a real stack though (usually the first one from the callback that started profiling), leading to the profiler recording the sample as being active in the frames of stack 0 instead of idle.

This PR creates an empty stack if the sample has no stack attached, assign its ID to the sample, and reuses it across the profile, matching the behavior of the legacy profiler.

Fixes #25757

Co-Authored-By: GPT-6 <codex@openai.com>
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 8f9412e (PR test merge using develop at f75f15b)

Against: f75f15b (develop) · base run #63873

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

Path Size % Change Change
@sentry/browser 30.33 kB - -
@sentry/browser - with treeshaking flags 28.45 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.34 kB - -
@sentry/browser (incl. Tracing) 52.54 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.54 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.49 kB +0.05% +26 B 🔺
@sentry/browser (incl. Tracing, Replay) 92.3 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.18 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.04 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.03 kB - -
@sentry/browser (incl. Feedback) 47.89 kB - -
@sentry/browser (incl. sendFeedback) 35.4 kB - -
@sentry/browser (incl. FeedbackAsync) 40.51 kB - -
@sentry/browser (incl. Metrics) 31.34 kB - -
@sentry/browser (incl. Logs) 31.62 kB - -
@sentry/browser (incl. Metrics & Logs) 32.3 kB - -
@sentry/react 32.14 kB - -
@sentry/react (incl. Tracing) 54.82 kB - -
@sentry/vue 38.46 kB - -
@sentry/vue (incl. Tracing) 55.45 kB - -
@sentry/svelte 30.36 kB - -
@sentry/remix (Remix 3 client bundle) 57.59 kB - -
CDN Bundle 32.06 kB - -
CDN Bundle (incl. Tracing) 53.02 kB - -
CDN Bundle (incl. Logs, Metrics) 34.26 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 54.99 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 75.25 kB - -
CDN Bundle (incl. Tracing, Replay) 90.74 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 92.67 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.85 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 98.82 kB - -
CDN Bundle - uncompressed 94.29 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.14 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.84 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 163.11 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 231.06 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 277.48 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 283.44 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 291.18 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 297.13 kB - -
@sentry/nextjs (client) 57.69 kB - -
@sentry/sveltekit (client) 53 kB - -
@sentry/core/server 43.69 kB - -
@sentry/core/browser 13.81 kB - -
@sentry/node 154.24 kB +0.02% +16 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.62 kB - -
@sentry/node - without tracing 95.55 kB +0.02% +15 B 🔺
@sentry/node - without channel injection 134.9 kB +0.01% +2 B 🔺
@sentry/aws-serverless 103.71 kB +0.01% +6 B 🔺
@sentry/cloudflare (withSentry) - minified 197.28 kB - -
@sentry/cloudflare (withSentry) 490.08 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 217.86 kB - -

View base workflow run

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 7 not successful, 58 successful. See the run.

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

@msonnb
msonnb marked this pull request as ready for review October 27, 2026 15:12
@msonnb
msonnb requested a review from a team as a code owner October 27, 2026 15:13
@msonnb
msonnb requested review from Lms24 and logaretm and removed request for a team October 27, 2026 15:13

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

Minor refactor, LGTM! ✅

Comment thread packages/browser/src/profiling/utils.ts Outdated
Comment on lines +150 to +164
let emptyStackId: number | undefined;
const samples: ContinuousThreadCpuProfile['samples'] = [];
for (let i = 0; i < input.samples.length; i++) {
const sample = input.samples[i];
if (!sample) {
continue;
}
let stackId = sample.stackId;
if (stackId === undefined) {
if (emptyStackId === undefined) {
emptyStackId = input.stacks.length;
stacks[emptyStackId] = [];
}
stackId = emptyStackId;
}

@logaretm logaretm Oct 27, 2026 •

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.

l: The empty stack's id is always input.stacks.length, so I think we can drop the lazy tracking:

Suggested change
let emptyStackId: number | undefined;
const samples: ContinuousThreadCpuProfile['samples'] = [];
for (let i = 0; i < input.samples.length; i++) {
const sample = input.samples[i];
if (!sample) {
continue;
}
let stackId = sample.stackId;
if (stackId === undefined) {
if (emptyStackId === undefined) {
emptyStackId = input.stacks.length;
stacks[emptyStackId] = [];
}
stackId = emptyStackId;
}
const emptyStackId = input.stacks.length;
const samples: ContinuousThreadCpuProfile['samples'] = [];
for (let i = 0; i < input.samples.length; i++) {
const sample = input.samples[i];
if (!sample) {
continue;
}
const stackId = sample.stackId ?? emptyStackId;
if (stackId === emptyStackId) {
stacks[emptyStackId] ??= [];
}

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.

nice, thx!

Co-Authored-By: GPT-6 <codex@openai.com>
@msonnb
msonnb merged commit 7def1fe into develop Oct 28, 2026
399 of 406 checks passed
@msonnb
msonnb deleted the ms/browser-profiling-idle-stacks branch October 28, 2026 08:52
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.

UI profiling: idle samples are attributed to stack 0 in convertToContinuousProfile

2 participants