Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line number printed in the tracing stack is not correct #2390

Closed
yuqingc opened this issue May 22, 2019 · 4 comments
Closed

Line number printed in the tracing stack is not correct #2390

yuqingc opened this issue May 22, 2019 · 4 comments

Comments

@yuqingc
Copy link
Contributor

yuqingc commented May 22, 2019

Here's my file test.ts

// test.ts
// ...

throw new Error('An error occurred here');

I ran deno run test.ts I got this:

[1/1] Compiling file:///Users/.../test.ts

/Users/matt/Projects/playground/denodemo/test.ts:3:6
throw new Error('An error occurred here');
      ^
Uncaught Error: An error occurred here
    at file:///Users/.../test.ts:4:7

The number of the line where the error occurs is expected to be 4 but I got 3 in the above line. (The number reported by tsc itselft is correct, obviously)

Platform: macOS/Linux
Deno version: 0.6.0

I also came across this issue when I tried checking out which line caused the failure of my pr in Azure pipeline. I checked the log and got the wrong line number, too...

@bartlomieju
Copy link
Member

Ref #1559

@kitsonk
Copy link
Contributor

kitsonk commented May 23, 2019

There seems to be variability in errors on if they are 0 or 1 indexed when they come from V8 and when the source mapped is applied.

Thanks for the reproduction, we should be able to try to fix that then.

@ry ry mentioned this issue Jun 7, 2019
43 tasks
@kt3k
Copy link
Member

kt3k commented Jun 20, 2019

In master branch, deno seems handling the above example correctly. (maybe fixed in #2487)

$ ./target/debug/deno test.ts 
[1/1] Compiling file:///Users/kt3k/s/deno/test.ts

error: Uncaught Error: An error occurred here
► file:///Users/kt3k/s/deno/test.ts:4:7

4 throw new Error('An error occurred here');
        ^

    at file:///Users/kt3k/s/deno/test.ts:4:7

@kitsonk
Copy link
Contributor

kitsonk commented Jun 20, 2019

Ah, I had forgot about this, but I do think #2487 did fix this. What was happening was that we weren't previously remapping the "outer" part of the error, only the stack trace, so the source line, start column and end column were the emitted file, not the original file. Now they are all the original file.

🎉

@ry ry closed this as completed Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants