Skip to content

support node --enable-source-maps usage with our custom Error.prepareStackTrace usage #3833

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

Closed
trentm opened this issue Jan 15, 2024 · 2 comments
Labels
agent-nodejs Make available for APM Agents project planning.

Comments

@trentm
Copy link
Member

trentm commented Jan 15, 2024

As of Node.js v21.6.0, node's internal prepareStackTrace function that handles source-map conversion for stack traces -- for the --enable-source-maps CLI option -- is exposed (as Error.prepareStackTrace).

That means that it should be possible chain our prepareStackTrace handling (which we use for parsing details from an exception for error reporting), with the core Node.js one when the user has used this CLI option.

@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Jan 15, 2024
@trentm
Copy link
Member Author

trentm commented Apr 15, 2025

See the long notes and discussion at #2833

@trentm
Copy link
Member Author

trentm commented Apr 15, 2025

Actually I was looking at details here for a customer support issue, and I believe we do work with node --enable-source-maps ... in versions of node that include nodejs/node#50827

This is because it was exposed as Error.prepareStackTrace and our prepareStackTrace code (in error-callsites) will use that: https://github.com/watson/error-callsites/blob/917208c601c88fcec2abb4dc3bdc17655f75e45b/index.js#L7

So Node.js versions v20.12.0, v21.6.0, and later should just work.
In versions before that a started elastic-apm-node agent will break node --enable-source-maps ....

@trentm trentm closed this as completed Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-nodejs Make available for APM Agents project planning.
Projects
None yet
Development

No branches or pull requests

1 participant