Skip to content

fix(sourcemaps): limit debug ID registration to one stack frame - #2543

Closed
amortemousque wants to merge 0 commit into
masterfrom
codex/debug-id-stack-limit
Closed

amortemousque wants to merge 0 commit into
masterfrom
codex/debug-id-stack-limit

Conversation

@amortemousque

@amortemousque amortemousque commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What and why?

Fixes #2537. Limit debug ID registration to the injected function's stack frame to avoid expensive source-position collection for large bundles. Registration remains synchronous and preserves the bundle URL used by the Browser SDK.

How?

Use the exact runtime snippet from #2542 (921e090): temporarily set Error.stackTraceLimit to 1 while constructing the error, then restore the original value in finally before reading .stack. No descriptor checks or additional fallback logic. The outer catch keeps application execution running if capture fails; a failing strict-mode assignment can skip registration.

Keep only two focused runtime tests: one-frame bundle registration with restoration before formatting, and restoration when error construction throws.

Validation: yarn build, yarn lint (0 errors; existing warnings), and all 118 sourcemap tests pass.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)

Related build-plugins PR: DataDog/build-plugins#553

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Tests

✅ All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: aff78e6 | Docs | View more details | Give us feedback!

@amortemousque
amortemousque force-pushed the codex/debug-id-stack-limit branch from aff78e6 to a17526b Compare October 7, 2026 08:00
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.

sourcemaps inject snippet adds ~260ms main-thread time to first loads of large bundles (top-level new Error().stack)

1 participant