Skip to content

sourcemap inject/upload mints a second debug ID for a file that registers one but has no //# debugId= comment #2269

Open

Description

@esetnik

Summary

When a file already registers a debug ID through a runtime snippet, but has no //# debugId= comment and no ID in its source map, sentry sourcemap inject and sentry sourcemap upload do not reuse that ID. They mint a new one, write it to the comment and the map, and prepend a second snippet. The file then registers two different IDs at runtime, and the SDK reports the original one, which no uploaded source map carries.

This is separate from #2267. That issue is about not recognising a snippet when the ID is already known from the comment or the map. Here the snippet is recognisable, but nothing reads the ID from it. It is not a regression: 0.45.0 behaves the same way.

When it happens

@sentry/vite-plugin 11.12.0 on Vite 8 leaves its output in this state: each chunk gets the snippet, but the //# debugId= comment and the map's debug_id are only added to the copies the plugin uploads. Running the CLI on that output directory, for example with the plugin's own upload turned off, hits this.

A file whose comment carries one ID while its snippet registers another behaves the same way: a snippet is added for the comment's ID.

Minimal reproduction

a.js:

!function(){try{var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="11111111-2222-4333-8444-555555555555",e._sentryDebugIdIdentifier="sentry-dbid-11111111-2222-4333-8444-555555555555");}catch(e){}}();
globalThis.answer = 42;
//# sourceMappingURL=a.js.map

a.js.map:

{"version":3,"file":"a.js","sources":["a.ts"],"sourcesContent":["globalThis.answer = 42;"],"names":[],"mappings":";AAAA"}

Run:

npx sentry@0.49.0 sourcemap inject .

Actual result

  • a.js gains a new first line with a snippet for a new ID, 0431efa2-2eee-43a9-992f-0939b29927c2, and a //# debugId= comment for that ID.
  • a.js.map gets debug_id and debugId set to the new ID, and mappings changes from ;AAAA to ;;AAAA.
  • Evaluating a.js leaves two entries in _sentryDebugIds, in this order: 0431efa2-… (new), then 11111111-… (original).
Tool Comment and map ID IDs registered at runtime, in order
sentry 0.45.0 new new, original
sentry 0.49.0 new new, original
main with #2268 applied new new, original
@sentry/cli 3.8.2 new new, original

Why it matters

getFilenameToDebugIdMap in @sentry/core 11.12.0 walks the registry keys in insertion order and assigns filename -> debugId for each, so the last registration for a file wins. The prepended snippet runs first and the original runs second, so events carry the original ID. The source map was uploaded under the new ID, so a lookup by debug ID finds nothing.

I confirmed the two registrations and read the SDK code. I did not send an event to Sentry to observe the failed lookup.

Expected result

When a file has no comment and no map ID but does register an ID at runtime, reuse that ID: write it to the comment and the map, and do not add a snippet. The sentry-dbid-<id> marker and the registry write both carry it.

Fix

Submitted in #2270.

Activity

  1. linear-code commented on Nov 14, 2026

    @linear-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions