Skip to content

Issue in consumer.originalPositionFor method is returning the lineNumber of next line of code in NextJs #479

Description

@ankit-meesho

So, I have implemented the source-map package and I am trying to find the lineNumber and originalFile of the production error from the JS chunk. I have implemented in in create-react-app and it's working fine.

But when I am implementing it in NextJS it's returning the lineNumber of the next piece of code where the error is getting generated.
For eg: If the error is introduced in lineNumber 45 and then next piece of code is written in lineNumber 50, in between line number 45 and 50 is space then I am getting line Number as 50 from consumer.originalPositionFor.

Implementation Details:

Implemented Source Map package like this :
rawSourceMap -- is the source map file for JS chunk where the error occurred.
Getting this info from the first frame of the error stack trace.

const consumer = await new SourceMapConsumer(rawSourceMap);
const originalPosition = consumer.originalPositionFor({
  line: lineNumber,
  column: columnNumber,
});
return originalPosition;

Activity

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

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions