-
-
Notifications
You must be signed in to change notification settings - Fork 536
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 numbers in error stack not changing #268
Comments
Can you please share more information about your project? There's not much to go off here. Things like:
|
tsconfig.json: {
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"noImplicitUseStrict": true,
"noImplicitAny": false,
"allowJs": true,
"allowSyntheticDefaultImports": true
}
} I am running js file with I just hit enter five times. My project is for generating code from typescript declarations.
I think there is some kind of cache of typescript files, and |
If there is a cache issue, it seems like it'd be coming from TypeScript and not |
Okay, tomorrow I will put together example project. |
Thanks, that'll be really helpful to me! I don't always have time to replicate the exact same scenarios so something I can quickly clone make my like 100x easier and faster to narrow down or fix any issues 👍 |
Here is the example project: You will find instructions to replicate problem inside server.js file. Thank you for support. |
@blakeembrey, I'm experiencing a similar issue when running Protractor tests through ts-node. The line and column numbers of the stack traces of errors thrown in the test files themselves are never correct. This is tricky, of course, as test expectations fail frequently and having an accurate stack trace is crucial. Here's a minimal example which allows you to reproduce this issue: https://github.com/renehamburger/ts-node-stack-problem. This example shows, that the *.ts file executed through ts-node has wrong stack traces, whereas the *.js pre-compiled with tsc with source maps has correct stack traces. I have not been able to reproduce this issue with simpler test cases, e.g. in a single TypeScript file. Usually the stack trace is absolutely accurate. Is this more likely to be a source-map-support issue? |
I discovered the culprit! Protractor activates it's own source-map-support, which probably conflicts with the one in ts-node. Adding a I'll post an issue at source-map-support to either resolve this issue or log a warning when it's activated multiple times. |
All of a sudden my lines are off on stacktraces again. I am passing the tsconfig.json using --project so sourceMap support is on and I am loading source-map-support anywhere I can see. I am not quite sure how to resolve the offsets? |
I tracked this down to an issue with invalidating sourcemap cache in source-map-support. Without such an API, we can't tell source-map-support that it needs to fetch a new sourcemap from us. See: evanw/node-source-map-support#281 where I have requested a cache invalidation API |
@cspotcode We might be able to specify |
@blakeembrey yeah, that could work. Do you know, are non- |
@cspotcode I don't, but I assume yes and it could lead to some extra FS calls for other packages. |
Is this issue why I'm seeing my stack line numbers be wrong when running mocha tests with |
Same question here. Using something like this, I'm getting no meaningful file/line-numbers. |
In my code generator project, I watch directory and on each change do require.cache cleaning and rerequire modules from that directory.
And I use stack to implement one important feature.
Rerequire works fine, because each time file changes, I see that console.log, meaning file is actually rerequired.
But if I move
var stack = new Error().stack;
down by 5 lines, I still get:If I do same experiment in pure js and node - it works fine.
So the only moving part between working version and not working version is
node server.js
andts-node server.js
The text was updated successfully, but these errors were encountered: