feat(sourcemaps): add local debug ID finder - #2471
Conversation
|
✅ All CI checks and tests passed. 🎉 All green!🧪 All tests passed 🔗 Commit SHA: 9b92dc4 | Docs | View more details | Give us feedback! |
There was a problem hiding this comment.
Large sourcemap sets can use all available Node.js memory. The resolver can also report wrong results for absent, unreadable, or malformed bundles.
🤖 Datadog Autotest · Commit ab03a5f · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
|
|
||
| const readSourcemapDebugId = async (sourcemapPath: string): Promise<SourcemapDebugIdResult> => { | ||
| try { | ||
| const parsed = JSON.parse(await fs.promises.readFile(sourcemapPath, 'utf8')) as unknown |
There was a problem hiding this comment.
Full sourcemap reads can use all memory
The command can use all available Node.js memory and stop before it returns results for a large build.
Assertion details
- Input: Run the resolver with default concurrency on many large sourcemaps that contain sourcesContent.
- Expected:
The resolver must read the debug ID with bounded memory or use a separate safe limit for full-map reads. - Actual:
The resolver reads and parses each complete sourcemap. Default concurrency permits 20 complete maps in memory at the same time.
Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
Fixed in 7a569df6. Sourcemaps are now parsed incrementally in 64 KiB chunks with bounded memory. Large sourcesContent values are scanned without being retained, and tests cover large maps plus debug_id values split across chunk boundaries.
| await fileHandle.close() | ||
| } | ||
| } catch { | ||
| return undefined |
There was a problem hiding this comment.
Bundle read errors look like missing IDs
The output directs users to fix instrumentation when the bundle is absent or unreadable.
Assertion details
- Input: Use --missing-debug-id when legacy discovery finds an orphan .js.map file or a bundle cannot be read.
- Expected:
The resolver must report the bundle read error and must not classify it as a missing debug ID. - Actual:
extractDebugIdAsync catches every bundle read error and returns undefined. The resolver then treats the bundle as if it exists without a debug ID.
Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
Fixed in 7a569df6. Asynchronous bundle extraction now returns file-read errors explicitly. The find command reports the error, excludes that artifact from --missing-debug-id results, and exits with status 1. A regression test covers an orphan sourcemap whose bundle is absent.
| } | ||
|
|
||
| const searchableContent = overlap + buffer.toString('utf8', 0, bytesRead) | ||
| const debugId = matchDebugId(searchableContent) |
There was a problem hiding this comment.
Malformed bundle IDs pass validation
The command hides the bundle from --missing-debug-id and cannot find it with a valid --debug-id query.
Assertion details
- Input: A bundle contains a 36-character ddDebugId value with misplaced hyphens.
- Expected:
The resolver must validate extracted bundle IDs with the same UUID shape that it uses for query and sourcemap IDs. - Actual:
The shared matcher accepts any 36 hex or hyphen characters. The resolver treats a malformed value as a valid bundle debug ID.
Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest
There was a problem hiding this comment.
Fixed in 7a569df6. Extracted bundle values are now validated with the shared strict UUID matcher. A malformed ddDebugId produces an explicit error, is excluded from --missing-debug-id results, and is covered by a command-level regression test.
What and why?
Adds a read-only
datadog-ci sourcemaps findcommand for RUM-18157.The command helps troubleshoot sourcemaps missing from Error Tracking by finding local minified JavaScript bundles and their corresponding sourcemaps, then showing the debug ID found in each artifact.
It supports two queries:
The output classifies each pair as
matched,bundle-only,sourcemap-only,mismatched,missing, orerror.--jsonprovides machine-readable output.This command only inspects local artifacts. It does not claim whether Datadog received or processed a sourcemap; remote lookup can be added separately in the future.
How?
sourceMappingURLreferences and legacy filename pairing.ddDebugIdvalues from minified bundles asynchronously.debug_idand ignoring nested values such as text insourcesContent.Validation
yarn test packages/base/src/commands/sourcemaps packages/datadog-ci/src/__tests__/cli.test.ts --runInBand --watchman=false— 7 suites, 258 testsyarn buildyarn lintyarn lint:packagesyarn lint:readme-usagesourcemaps findvalidation against local artifact fixturesReview checklist