Skip to content

npm packages @sentry/core and @sentry/utils have invalid 'sources' path in *.js.map files #12642

Closed
@alexandersorokin

Description

@alexandersorokin

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/browser

SDK Version

8.11.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

Any

Steps to Reproduce

Scenario A:

  1. Create new Vite project;
  2. Install @sentry/browser;
  3. Call Sentry.init in code;
  4. Run Vite in dev mode;
  5. Open devtools and navigate to Sources/Debugger tabs;
  6. Open node_modules folder.

Scenario B:

  1. Create new Vite project;
  2. Install @sentry/browser;
  3. Call Sentry.init;
  4. Add sourcemaps plugin to vite.config.ts;
  5. Run Vite build.

Expected Result

Scenario A:

Sources for @sentry/core are located in node_modules/@sentry/core folder in Sources/Debugger.
And sources for @sentry/utils are located in node_modules/@sentry/utils folder in Sources/Debugger.

Scenario B:

Build is successful.

Actual Result

Scenario A:

Sources for both @sentry/core and @sentry/utils are mixed and found in different folders. They are found in:

  1. node_modules/src.
  2. node_modules/@sentry/src.

See screenshots:
image
image

Scenario B:

Build fails with error:

Multiple conflicting contents for sourcemap source D:\work\test-widget\node_modules\@sentry\src\envelope.ts
    at getRollupError (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/parseAst.js:396:41)
    at error (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/parseAst.js:392:42)
    at Link.traceMappings (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17774:32)
    at collapseSourcemaps (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17858:63)
    at transformChunk (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17962:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18008:17
    at async Promise.all (index 1)
    at async transformChunksAndGenerateContentHashes (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:18003:5)
    at async renderChunks (file:///d:/work/test-widget/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:17912:137) {
  code: 'SOURCEMAP_BROKEN'
}

Analysis:

Errors are caused by the content of *.js.map files in published npm packages. Field sources contains extra ../ (to parent folder). As a result, the sources path is mapped outside its own package folder.

Build fails because sources of envelope.js from both @sentry/core and @sentry/utils maps by envelope.map.js to the same path: D:\work\test-widget\node_modules\@sentry\src\envelope.ts.

See screenshot:
image

In order to fix the issue, the path should be ../src/envelope.ts instead of ../../src/envelope.ts or the content of entire packages should be in an additional subfolder.

Metadata

Metadata

Assignees

Labels

Package: browserIssues related to the Sentry Browser SDK

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions