Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
This PR has had no activity for 3 days. It closes in 2 days unless someone pushes, comments, or adds the |
There was a problem hiding this comment.
Thanks for this, @esetnik. The fix looks right to me, and the write-up made it easy to check.
What I verified:
- The premise holds.
getFilenameToDebugIdMapin@sentry/coreassignsfilename -> debugIdper registry key in insertion order, and_debugIdsis processed after_sentryDebugIds. So any registration already in the file beats a prepended snippet, and reusing that ID is the only way the uploaded map matches what events carry. - The branch rebases cleanly onto current
main(165 commits ahead, including #2268 and the TS 7 move). On the rebased copy,inject.test.tsand the rest of the sourcemap tests pass, and the two "reuses an ID" cases fail with thesrc/change reverted. The CLI test typecheck passes, and oxlint and oxfmt are clean on the touched files. - Because
readRegisteredDebugIdreusesDEBUGID_REGISTRATION_RE, it picks up every form #2268 added. I checked it against the plugin snippet, the Oxc template-literal rewrite, Turbopack's(e._debugIds||(e._debugIds={}))[n]and||=forms, Metro's bare_sentryDebugIds[stack], and the bracketed key. Each returns the ID. Registry reads, thesentry-dbid-marker alone, a//# debugId=comment, and identifiers that only end in_sentryDebugIdsreturn nothing. - The comment,
debug_id/debugId, and the runtime registry all end up on one ID.mappingsis left unshifted on both the external and inline paths, the dry run reports the reused ID, and a second run is a no-op. Ran the #2269 repro through the CLI from source and got the same result. Binary bundles andskipSnippetare not read, which matches the existing guards.react-native gradlegoes throughinjectDebugIdtoo and gets the same behavior.
One small ask, not a blocker: since Vite 8 + Oxc is the case that motivated this, a reuse case with the template-literal snippet would pin that path down. The regex has its own coverage from #2268, but nothing yet checks the reuse end to end for the minified form.
Could you rebase onto main? It merges cleanly. CI on fork PRs needs a maintainer to approve the workflow runs, so the Test/Warden runs on this head never actually ran. A fresh push also resets the stale timer.
Heads-up: #2248 (minified snippet detection, Vite 8 line shift) is being worked on in parallel and touches the same regex area. Your change should pick up anything it widens automatically, but whichever lands second may need a small rebase.
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>
39cc4d4 to
b511d85
Compare
|
@esetnik is attempting to deploy a commit to the Sentry Team on Vercel. A member of the Team first needs to authorize it. |
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