fix(error-tracking): wait for debug ID injection before sourcemap upload - #487
Open
jhssilva wants to merge 1 commit into
Open
fix(error-tracking): wait for debug ID injection before sourcemap upload#487jhssilva wants to merge 1 commit into
jhssilva wants to merge 1 commit into
Conversation
jhssilva
marked this pull request as ready for review
August 14, 2026 08:04
jhssilva
requested review from
buranmert and
nchapma2
and removed request for
a team
August 14, 2026 08:04
|
relevant comment from the previous PR: #470 (comment) |
There was a problem hiding this comment.
Pull request overview
Friend, this PR synchronizes esbuild artifact rewriting with Error Tracking sourcemap uploads.
Changes:
- Adds an artifact-readiness barrier to shared context.
- Delays and deduplicates sourcemap uploads until injection finishes.
- Adds barrier and debug-ID regression coverage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/core/src/types.ts |
Defines artifact barrier APIs. |
packages/factory/src/helpers/context.ts |
Implements barrier lifecycle. |
packages/factory/src/helpers/context.test.ts |
Tests resolution, rejection, and reuse. |
packages/plugins/injection/src/index.ts |
Marks esbuild artifacts pending. |
packages/plugins/injection/src/esbuild.ts |
Resolves the barrier after rewriting. |
packages/plugins/error-tracking/src/index.ts |
Gates and deduplicates uploads. |
packages/plugins/error-tracking/src/index.test.ts |
Adds synchronization and debug-ID tests. |
packages/tests/src/_jest/helpers/mocks.ts |
Extends context mocks. |
Suppressed comments (1)
packages/plugins/error-tracking/src/index.test.ts:111
- Split the mapped promise and the push into named steps. The current nested calls violate the repository’s call-argument convention and make this assertion setup harder to follow.
debugIdsAtUpload.push(
...(await Promise.all(
javascriptOutputs.map(({ filepath }) => extractDebugId(filepath)),
)),
);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| const handleOrQueueSourcemaps = async () => { | ||
| if (context.artifactsPending) { | ||
| context.queue(handleSourcemaps()); |
| ); | ||
| const plugin = getPlugins(arg)[0]; | ||
|
|
||
| const buildReportHook = plugin.buildReport!(getMockBuildReport()); |
buranmert
approved these changes
Aug 14, 2026
buranmert
left a comment
There was a problem hiding this comment.
that's a bit beyond my understanding of JS build plugins for me to propose a better way to achieve that.
i'm fine as long as our end-to-end tests pass 👍
This was referenced Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add an explicit artifacts-ready barrier so Error Tracking waits until esbuild finishes rewriting JavaScript and source-map artifacts before discovering sourcemaps and extracting debug IDs.
The early esbuild build-report callback queues the gated upload instead of blocking the later injection callback. Concurrent lifecycle attempts share one upload promise.
Why
RUM-18038 live testing showed esbuild uploaded all sourcemaps but extracted debug IDs for 0/N because upload ran before debug-ID injection completed.
How it works
.jsand.mapartifact is ready.ddDebugId, and uploads that value with the final JavaScript and sourcemap.The uploader does not inject or modify the bundle. The synchronization prevents it from reading or uploading artifacts while esbuild is still rewriting them.
Tests
Jira: https://datadoghq.atlassian.net/browse/RUM-18038