Repository navigation
Conversation
A bundler plugin leaves its snippet in each output file, but adds the `//# debugId=` comment and the map's ID only to the copies it uploads. Given that output, `sourcemap inject` and `sourcemap upload` found no ID, minted one and prepended a second snippet. The bundle then registered two IDs, and the SDK reports the one registered last, which is the original and not the one the sourcemap was uploaded under. When a file has no comment and no map ID but registers exactly one ID at runtime, reuse it: write the comment and the map ID, and add no snippet. A file that registers several different IDs still gets its own, as before. Fixes getsentry#2269 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This branch was previously deployed
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.
Summary
Fixes #2269.
A bundler plugin leaves its runtime snippet in each output file, but adds the
//# debugId=comment and the map's ID only to the copies it uploads. Given that output,sentry sourcemap injectandsentry sourcemap uploadfound no ID, minted one, and prepended a second snippet. The bundle then registered two different IDs.getFilenameToDebugIdMapin@sentry/corekeeps the one registered last, which is the original, so events carried an ID that no uploaded sourcemap had.When a file has no comment and no map ID but registers exactly one ID at runtime, that ID is now reused: the comment and the map ID are written, and no snippet is added.
Changes
readRegisteredDebugIdindebug-id.tsreturns the ID a file registers throughDEBUGID_REGISTRATION_RE, when it registers exactly one. Several different IDs do not identify one bundle, so it returns nothing and the file gets its own ID and snippet as before.injectDebugIdandinjectInlineDebugIdfall back to it after the comment and the map. With a reused ID they skip the snippet and leavemappingsunshifted. Binary bundles are not read.injectDirectoryreports the reused ID in place of(pending). It still reportsinjected: true, since the file changes.inject.test.ts, each for external and inline maps: the ID is reused (file still starts with its own snippet, comment and map ID written,mappingsunchanged, one ID registered at runtime, second run a no-op), and a file registering two different IDs is still given its own.Not changed: a file whose comment carries one ID while its snippet registers another still gets a snippet for the comment's ID. Which of the two should win is a separate decision.
Relation to #2268
This is independent of #2268 and based on
main. They touch nearby lines but merge cleanly. The ID is read with the same registration regex, so until #2268 lands a snippet that Oxc has rewritten to a template literal is not read here either, and such a file is handled as before.Verification
Run locally on macOS, on
39cc4d4:pnpm run tsc: passes.pnpm run lintat the repo root: passes.inject.test.ts: 58 passed. With the source change reverted, the two "reuses an ID" cases fail.pnpm run testinpackages/cli: 13,160 passed, 28 failed, 57 skipped. The same 28, in the same six files, fail on unmodifiedmainon this machine:debug-files/upload,build/car-extract.integration,build/zip-writer,delta-upgrade.mocked,install-scriptandtime-range.pnpm run test:e2einpackages/cli: 206 passed, 1 failed, 3 skipped. The failure istelemetry-exit, a timing assertion that passes when run on its own, on this branch and onmain.sourcemap inject/uploadmints a second debug ID for a file that registers one but has no//# debugId=comment #2269, through the CLI run from source: one ID in the comment, the map and the runtime registry, no added line,mappingsunchanged.@sentry/vite-plugin11.12.0 (2,050 lines, snippet minified by Oxc): the plugin's ID was written to the comment and the map, the file still starts with the plugin's snippet, andmappingsis unchanged.Not done: no event was sent to Sentry to observe symbolication end to end.
🤖 Generated with Claude Code