Skip to content

Injecting debug IDs into angular source maps breaks original map #8723

Closed
@InterstellarStella

Description

@InterstellarStella

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/angular-ivy

SDK Version

7.61.0

Framework Version

Angular 15.1.0

Link to Sentry event

https://dragonfruit-dev.sentry.io/issues/4364427077/?query=is%3Aunresolved&referrer=issue-stream&stream_index=0

SDK Setup

Sentry.init({
  dsn: "DSN_HERE",
  integrations: [
    new Sentry.BrowserTracing({
      tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
      routingInstrumentation: Sentry.routingInstrumentation,
    }),
    new Sentry.Replay(),
  ],
  tracesSampleRate: 1.0,
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 1.0,
  release: "angular@1.5.2",
});

Steps to Reproduce

  1. sentry-cli version is 2.20.3
  2. ng build
  3. sentry-cli sourcemaps inject ./dist
  4. sentry-cli sourcemaps upload --release=angular@1.5.2 ./dist/angular-tour-of-heroes --org dragonfruit-dev -p javascript-angular

Expected Result

The source maps are uploaded to Sentry and correctly matched to new events.

Actual Result

After running the inject command, I noticed that there is a ; being added into the "mappings" part of the .map files.
Screenshot 2023-08-02 at 19 54 38

This breaks the source map in the browser, as an error's position seems to be wrong
Screenshot 2023-08-02 at 19 53 21
Screenshot 2023-08-02 at 19 54 05

Additionally, in the stack trace section in the resulting error in Sentry, we see repeating positions and we don't get readable code:
https://dragonfruit-dev.sentry.io/issues/4364427077/?query=is%3Aunresolved&referrer=issue-stream&stream_index=0
Screenshot 2023-08-02 at 19 59 36

A temporary fix is to manually remove the ; from all the .map files and after injecting the debug IDs and before uploading the source maps to Sentry. I found that this gave me the correct stack traces:
https://dragonfruit-dev.sentry.io/issues/4364645800/?query=is%3Aunresolved&referrer=issue-stream&stream_index=0
Screenshot 2023-08-02 at 20 22 24

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: angularIssues related to the Sentry Angular SDK

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions