elastic / elastic/apm-agent-nodejs
Support async error stack parser
- Dominant language
- JavaScript
- Stars
- 594
- Forks
- 244
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 16
Description
**Is your feature request related to a problem? Please describe.**
Hi, I'm using Elastic APM in our node projects and I found it lose stack trace when an async function throws an error.
ES APM can only trace the Error part, but lose "From previous event" part. The previous event is about the project code, which is I'm looking for.
Async functions are very commonly in node.js, I'm looking forward to APM can support async error stack parser.
**Describe the solution you'd like**
APM can trace the entire error stack.
**Describe alternatives you've considered**
In the source code I found the error stack is first handled by stackman, and the frames will lose "From previous event" part. I found if frames length is 0, error will be handled by error-stack-parser, and the error stack can be parsed correctly.
**Additional context**
code like this:
```js
const id = someAsyncFunction();
anotherFunction(id);
```
error like this:
```
nodejs.unhandledRejectionError: Invalid value Promise { }
at Object.escape (/node_modules/sequelize/lib/sql-string.js:65:11)
......
at processImmediate (internal/timers.js:439:21)
From previous event:
at Function.findAll (/node_modules/sequelize/lib/model.js:1755:8)
......
name: "unhandledRejectionError"
```
Contributor guide
Assessment
This issue has not been assessed yet.