Skip to content

fix(error-tracking): search debug IDs progressively - #489

Open
jhssilva wants to merge 1 commit into
masterfrom
hugo.silva/rum-18038-progressive-debug-id
Open

fix(error-tracking): search debug IDs progressively#489
jhssilva wants to merge 1 commit into
masterfrom
hugo.silva/rum-18038-progressive-debug-id

Conversation

@jhssilva

@jhssilva jhssilva commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What does this change?

Searches built JavaScript artifacts progressively for their injected ddDebugId instead of stopping after the first 1 KiB.

  • Reads in 1 KiB chunks.
  • Stops immediately after finding a valid debug ID, so the common case still performs one read.
  • Retains a 64-character overlap so an ID split across two reads is matched.
  • Keeps memory bounded to the current chunk plus overlap.
  • If no debug ID exists, accepts reading the artifact to EOF as the rare worst case.

This is intentionally separate from the bundler-specific fixes:

  • PR #487 coordinates esbuild post-build injection with sourcemap upload.
  • PR #488 keeps Rollup injection after normal chunk transforms.

Tracking issue: RUM-18038

Validation

  • 8/8 focused tests pass.
  • Covers the one-read common case, a debug ID after the first chunk, a debug ID split across chunks, an absent debug ID that scans to EOF, and unreadable files.
  • Focused lint and Error Tracking typechecking pass.

Exact PR package matrix:

Bundler IDs extracted before upload Runtime IDs observed Result
webpack 4/4 2/2 PASS
Vite 6/6 2/4 loaded IDs PASS
Rollup 4/4 2/2 PASS
esbuild 0/7 2/5 loaded IDs Expected failure without PR #487
Rspack 4/4 2/2 PASS

The Rollup result uses PR #489 without PR #488, confirming progressive discovery finds the entry debug ID beyond the initial 1 KiB.

The locally stacked PR #487 + PR #489 esbuild package extracted 7/7 debug IDs and observed both runtime-loaded IDs, confirming compatibility once artifact readiness is present.

All five exact PR packages also passed static production builds, deterministic rebuild checks, and browser entry/lazy registration. Staging RUM search returned zero indexed events for all generated targets during the retry window, despite successful browser intake, so this run could not revalidate downstream deobfuscation.

@jhssilva
jhssilva marked this pull request as ready for review August 14, 2026 13:56
@jhssilva
jhssilva requested a review from a team as a code owner August 14, 2026 13:56
@jhssilva
jhssilva requested review from buranmert and ksun154 and removed request for a team August 14, 2026 13:56
@buranmert
buranmert requested a lite review from Copilot August 14, 2026 15:02

Copilot AI 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

This PR updates the Error Tracking sourcemap pipeline to extract injected ddDebugId values by scanning built JavaScript artifacts progressively (in fixed-size chunks with overlap) instead of only inspecting the initial prefix, improving reliability across bundlers/transforms that may move the injected snippet later in the file.

Changes:

  • Replaces prefix-only reads with a progressive 1 KiB chunk scan that stops early on match and retains a small overlap for boundary-split literals.
  • Exposes the chunk size constant and adds unit tests covering early stop, later-in-file IDs, split-across-chunks IDs, scan-to-EOF, and unreadable files.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/plugins/error-tracking/src/sourcemaps/debugId.ts Implements progressive chunked scanning with overlap to find ddDebugId without reading entire bundles in the common case.
packages/plugins/error-tracking/src/sourcemaps/debugId.test.ts Adds coverage for the progressive read behavior and related edge cases.

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

Comment on lines +41 to +53
test('Should stop reading after finding the debug ID in the first chunk', async () => {
const literal = `ddDebugId:"${debugId}"`;
const read = jest.fn(async (buffer: Buffer) => {
buffer.write(literal);
return { bytesRead: literal.length, buffer };
});
const close = jest.fn(async () => undefined);
jest.spyOn(fsp, 'open').mockResolvedValue({ read, close } as never);

await expect(extractDebugId('first-chunk.min.js')).resolves.toBe(debugId);
expect(read).toHaveBeenCalledTimes(1);
expect(close).toHaveBeenCalledTimes(1);
});
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