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

reported stackframe provide wrong line number (on Windows) #1055

Closed
erossignon opened this issue May 23, 2020 · 5 comments
Closed

reported stackframe provide wrong line number (on Windows) #1055

erossignon opened this issue May 23, 2020 · 5 comments
Labels

Comments

@erossignon
Copy link

Expected Behavior

Expecting ts-node to report accurate stack frame, pointing to the original typescript file.

Steps to reproduce the problem

package.json

{
  "name": "tsnode-issue",
  "version": "1.0.0",
  "main": "index.js",
  "dependencies": {
    "typescript": "^3.9.3"
  }
}

test.ts

/* some comment */
function someFunc() {
    throw new Error("Error");
}
; (() => {
    try {
        /* some comment */
        someFunc();
    }
    catch (err) {
        /* some comment */
        console.log("Error Found", err);
    }
})();

( no tsconfig file necessary)

Minimal reproduction

npx: installed 8 in 2.249s
Error Found Error: Error
    at someFunc (c:\temp\tsnode-issue\test1.ts:3:11)
    at c:\temp\tsnode-issue\test1.ts:9:9
    at Object.<anonymous> (c:\temp\tsnode-issue\test1.ts:15:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Module.m._compile (C:\Users\eross\AppData\Roaming\npm-cache\_npx\23236\node_modules\ts-node\src\index.ts:858:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.require.extensions.(anonymous function) [as .ts] (C:\Users\eross\AppData\Roaming\npm-cache\_npx\23236\node_modules\ts-node\src\index.ts:861:12)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
npx: installed 8 in 2.184s
Error Found Error: Error
    at someFunc (c:\temp\tsnode-issue\test1.ts:3:11)
    at c:\temp\tsnode-issue\test1.ts:8:9
    at Object.<anonymous> (c:\temp\tsnode-issue\test1.ts:14:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Module.m._compile (C:\Users\eross\AppData\Roaming\npm-cache\_npx\17244\node_modules\ts-node\src\index.ts:839:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.require.extensions.(anonymous function) [as .ts] (C:\Users\eross\AppData\Roaming\npm-cache\_npx\17244\node_modules\ts-node\src\index.ts:842:12)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
  • spot the that the stack frame is wrong
    at c:\temp\tsnode-issue\test1.ts:9:9 incorrect with [email protected]
    where it should report
    at c:\temp\tsnode-issue\test1.ts:8:9 '(correct with [email protected]

In real production, the line number discrepancy can be large and annoying as it make it almost impossible to identify where the exception was raised ( annoying when doing TDD)

TypeStrong/ts-node-repros#3

Specifications

  • ts-node version: success with 8.9 : failure with 8.10.1 and 8.10.0
  • node version: 10.20.1
  • TypeScript version: 3.9.3
  • tsconfig.json, if you're using one:
{}
  • Operating system and version:
  • If Windows, are you using WSL or WSL2?:
    Bug can be reproduced on Windows from a DOS box,
    cannot exhibit bug in WSL
@cspotcode
Copy link
Collaborator

Thank you for the detailed report. This may be the same as #1037, which was fixed in #1038 but not yet published. Are you able to test with the latest master code?

npm install 'TypeStrong/ts-node#master'

@rinick
Copy link

rinick commented May 26, 2020

Thank you for the detailed report. This may be the same as #1037, which was fixed in #1038 but not yet published. Are you able to test with the latest master code?

npm install 'TypeStrong/ts-node#master'

I have a similar issue and the latest code in master branch works

@hbenl
Copy link

hbenl commented May 27, 2020

I hope you're going to publish the fix soon since this bug seems to be affecting Mocha Test Explorer (which uses stack traces to detect the test locations in the code).

erossignon added a commit to node-opcua/node-opcua that referenced this issue May 27, 2020
@cspotcode
Copy link
Collaborator

I should have time to publish a release on Saturday. Unfortunately I am swamped at work this week, so that's the soonest I will be able to work on ts-node stuff.

Maybe @blakeembrey is able to publish a new release in the meantime?

@cspotcode
Copy link
Collaborator

@hbenl @erossignon @rinick
Published 8.10.2 which includes this fix. Thanks for your patience.
Thanks to @jugglingthebits for testing the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants