Deno: Line number printed in the tracing stack is not correct

Created on 22 May 2019  Â·  4Comments  Â·  Source: denoland/deno

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...

Most helpful comment

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.

🎉

All 4 comments

Ref #1559

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.

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

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.

🎉

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CruxCv picture CruxCv  Â·  3Comments

sh7dm picture sh7dm  Â·  3Comments

ry picture ry  Â·  3Comments

davidbarratt picture davidbarratt  Â·  3Comments

ry picture ry  Â·  3Comments