Skip to content

Source mapping is offset when using switch statements #1863

@richardsimko

Description

@richardsimko

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

7.86.0

Framework Version

No response

Link to Sentry event

https://fl101.sentry.io/issues/4715851450/events/4f6786772d4045d4b57a56cab225e50e/

SDK Setup

N/A

Steps to Reproduce

https://github.com/richardsimko/sentry-sourcemap-bug

  1. yarn install
  2. yarn run tsc
  3. yarn run sentry-cli sourcemaps inject ./build
  4. yarn run sentry-cli sourcemaps resolve build/test.js.map -l 6 (To simulate the lookup from one of the errors)

This happens in the live Sentry environment as well, the stack trace in the linked event are also off by 2 lines.

Expected Result

Source line is line 7 in test.ts

Actual Result

Source line is line 5 in test.ts

source map path: "build/test.js.map"
source map type: regular
lookup line: 5, column: 0:
  name: not found
  source file: "/test.ts"
  source line: 5
  source column: 13
  minified line: 4
  minified column: 15
  source code:
    console.log("test2");
    
    switch (process.env.TEST) {
      case "test":
        throw new Error("test");
      default:
        throw new Error("default");

Metadata

Metadata

Labels

BugIssue type
No fields configured for issues without a type.

Projects

Status

Waiting for: Product Owner

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions