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

Fix TypeScript linenumbers on server stacktraces #1382

Closed
metasoarous opened this issue Apr 16, 2022 · 2 comments · Fixed by #1685
Closed

Fix TypeScript linenumbers on server stacktraces #1382

metasoarous opened this issue Apr 16, 2022 · 2 comments · Fixed by #1685
Assignees

Comments

@metasoarous
Copy link
Member

metasoarous commented Apr 16, 2022

Expected behavior:
If there's an exception on the server, stacktraces should be printed with line numbers corresponding to our actual TypeScript source so that we can navigate the code and figure out what happened.

Actual behavior:
Line numbers currently correspond to the compiled JS, making it difficult to interpret stack traces.

Additional context:
This came up in #1380, and complicated sorting out a solution.

Suggested solution:
It looks like there's a plugin for creating source mappings, the usage of which is described here:
https://stackoverflow.com/questions/50363449/how-to-get-error-information-relating-to-typescript-file-lines-number-in-node-js

@metasoarous metasoarous added the 🐣 good-first-issue Good issues for first time contributors label Apr 19, 2022
@metasoarous metasoarous changed the title Server stacktrace line numbers should correspond to TS source Fix TypeScript linenumbers on server stacktraces Apr 19, 2022
@SebastianRuan
Copy link
Contributor

I took a look at your suggested solution metasoarous and have it working on my end. However, the module only works with Error objects as it manipulates the stack property. Since primitive exceptions (throwing strings, numbers etc.) do not have a stack property they will not be correctly identified in stack traces. I noticed there are quite a few strings thrown in the .ts files. Would another solution be preferable?

@metasoarous
Copy link
Member Author

Awesome; Thanks for spearheading this @SebastianRuan!

I would support us rewriting our throws to use error objects if that gets us around this problem. We already have an issue up tracking overall improved logging (see #1379), and this would fit well with that.

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