Skip to content

fix(injection): keep Rollup debug IDs in upload prefix - #488

Open
jhssilva wants to merge 2 commits into
masterfrom
hugo.silva/rum-18038-rollup-debug-id
Open

fix(injection): keep Rollup debug IDs in upload prefix#488
jhssilva wants to merge 2 commits into
masterfrom
hugo.silva/rum-18038-rollup-debug-id

Conversation

@jhssilva

@jhssilvajhssilva commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What does this change?

Fixes Rollup sourcemap uploads that can miss the entry bundle's debug ID when a later transform pushes the complete ddDebugId value outside Error Tracking's initial read.

  • Runs Datadog's Rollup renderChunk injection with order: 'post', after normal transforms such as Terser.
  • Places ddDebugId first in the injected source-code context.

Progressive debug-ID discovery is intentionally handled separately by the follow-up PR linked below, because it changes shared Error Tracking behavior for every bundler.

Related fixes:

  • PR #487 fixes the esbuild artifact-readiness race.
  • PR #489 adds progressive debug-ID discovery for all bundlers.

Tracking issue: RUM-18038

Validation

  • Focused regression tests: 10/10 passed.
  • Lint, full typechecking, integrity, and dependency checks passed.
  • Static production builds and browser runtime registration passed for webpack, Vite, Rollup, esbuild, and Rspack.
  • Live Rollup staging test: 4/4 debug IDs extracted before upload and 2/2 errors deobfuscated.
  • Live webpack, Vite, and Rspack staging tests: all uploaded sourcemaps contained debug IDs and 2/2 errors deobfuscated for each bundler.
  • Exact esbuild PR fix(error-tracking): wait for debug ID injection before sourcemap upload #487 package: 7/7 debug IDs extracted and 2/2 errors deobfuscated.

@jhssilva
jhssilva marked this pull request as ready for review August 14, 2026 11:56
@jhssilva
jhssilva requested review from a team as code ownersAugust 14, 2026 11:56
@jhssilva
jhssilva requested review from tyffical and removed request for a teamAugust 14, 2026 11:56
@jhssilva

Copy link
Copy Markdown
ContributorAuthor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@jhssilvajhssilva changed the title fix(injection): keep Rollup debug IDs in upload prefixfix(error-tracking): find debug IDs progressivelyAug 14, 2026
@jhssilvajhssilva changed the title fix(error-tracking): find debug IDs progressivelyfix(injection): keep Rollup debug IDs in upload prefixAug 14, 2026
@jhssilva
jhssilvaforce-pushed the hugo.silva/rum-18038-rollup-debug-id branch from 817cc2d to 83a82fbCompareAugust 14, 2026 13:35
@jhssilva
jhssilvaforce-pushed the hugo.silva/rum-18038-rollup-debug-id branch from 83a82fb to 53b65e8CompareAugust 20, 2026 16:53
…8-rollup-debug-id
# Conflicts:
#	packages/plugins/error-tracking/src/sourcemaps/debugId.test.ts

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

disclaimer: i'm an outsider to rollup plugin. i approve as i don't see any obvious bug in this PR 👍

CopilotAI 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.

Pull request overview

Friend, this PR addresses Rollup sourcemap uploads missing the entry bundle’s debug ID by ensuring the injected ddDebugId stays within a bounded prefix read (and survives later Rollup transforms).

Changes:

  • Run the Rollup injection plugin’s renderChunk hook with order: 'post' so injections happen after normal transforms (e.g., Terser).
  • Serialize ddDebugId first in the RUM source-code-context snippet to keep it early in the emitted bundle.
  • Add/extend unit tests to assert debug ID ordering in the snippet and to cover the Rollup “late transform padding” scenario.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

FileDescription
packages/plugins/rum/src/index.test.tsAdds an ordering test for ddDebugId vs. other source code context metadata.
packages/plugins/rum/src/getSourceCodeContextSnippet.tsComputes debugId up front and ensures ddDebugId is serialized first in the context object.
packages/plugins/injection/src/rollup.tsSwitches renderChunk to an ordered hook (order: 'post') so injection runs after other chunk transforms.
packages/plugins/error-tracking/src/sourcemaps/debugId.test.tsAdds a Rollup-based regression test ensuring debug IDs remain within the bounded search prefix after later transforms.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +66 to +70
const code = value();

expect(code.indexOf('"ddDebugId"')).toBeLessThan(code.indexOf('"service"'));
expect(code.indexOf('"ddDebugId"')).toBeLessThan(code.indexOf('"version"'));
});
Comment on lines +141 to +142
const content = await readFile(outputPath);
expect(content.indexOf('ddDebugId')).toBeLessThan(DEBUG_ID_SEARCH_CHUNK_BYTES);
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@jhssilva@buranmert@amortemousque