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

Getting stack traces with and without source maps #51853

Closed
FStefanni opened this issue Feb 23, 2024 · 3 comments
Closed

Getting stack traces with and without source maps #51853

FStefanni opened this issue Feb 23, 2024 · 3 comments
Labels
feature request Issues that request new features to be added to Node.js. source maps Issues and PRs related to source map support. stale

Comments

@FStefanni
Copy link

What is the problem this feature will solve?

Hi,

I use Typescript, so I also use the --enable-source-maps flag for node, in order to debug easily the issues.
But actually, sometimes it is better to have stack traces without the source maps, inside the same code.

For example, if trying to get the module name, to pass it maybe to Worker() constructor, then it must be the transpiled JavaScript (and not the source TS).

There are methods to get the same info, but they are module-system dependent.
For example, __filename for CommonJS, and fileURLToPath(import.meta.url) for ESM, but their are not portable between module systems. So parsing the stack trace is the most portable way to get the actual current module.

Other uses can be when we are debugging code managed by a bundler/optimizer, it could be interesting to inspect also the actual stack trace (non source mapped). This is also important when there are "strange/unexpected behaviors" because the tsc program performs something not so expected (so we like to inspect also the actual JavaScript code).

Regards

What is the feature you are proposing to solve the problem?

It could be nice to be able to get the preferred trace format and module name programmatically, so that in the same program, we could be in a function to have the stack trace with source maps, and in another function without source mappings, just by passing an option.

What alternatives have you considered?

I checked module-system dependent options, but:

  1. They are module system dependent
  2. I have found no way to get a complete stack trace with/without source map programmatically

I also checked Node docs, but I have found none to solve this issue:

  • Error.prepareStackTrace: it already gets the source mapped stack trace infos
@FStefanni FStefanni added the feature request Issues that request new features to be added to Node.js. label Feb 23, 2024
@FStefanni FStefanni changed the title Getting stach traces with and without source maps Getting stack traces with and without source maps Feb 23, 2024
@legendecas legendecas added the source maps Issues and PRs related to source map support. label Feb 25, 2024
@legendecas
Copy link
Member

legendecas commented Mar 19, 2024

Replacing Error.prepareStackTrace could retrieve the original call sites info and perform custom decoration on the stack traces, as in #50733.

Copy link
Contributor

There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-stale Mark issue so that it is never considered stale label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot added the stale label Sep 16, 2024
Copy link
Contributor

There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. source maps Issues and PRs related to source map support. stale
Projects
None yet
Development

No branches or pull requests

2 participants