elastic / elastic/apm-agent-nodejs
Agent wrongly identify stack traces line for Typescript
- Dominant language
- JavaScript
- Stars
- 594
- Forks
- 244
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 16
Description
**Describe the bug**
The agent does capture stack trace but it wrongly claims that the line is 299 when it's 364 actually.
I first though it was a source map issue, but we do have the comment on the last line with a valid source map.
**To Reproduce**
Create a NestJS app, then install the apm agent and capture error in a error interceptor.
**Expected behavior**
We expect the stack trace to be good.
**Environment (please complete the following information)**
- OS: Linux
- Node.js version: 13.0
- APM Server version: 7.5.1 (we just updated it)
- Agent version: `"elastic-apm-node": "^3.3.0"`
**How are you starting the agent? (please tick one of the boxes)**
- [ ] Calling `agent.start()` directly (e.g. `require('elastic-apm-node').start(...)`)
**Additional context**
Our stack trace (on stdout):
```
webhook_1 | GraphQLError: GraphQL Error
webhook_1 | at GraphQLService.handleErrors (/usr/src/app/src/common/graphql/graphql.service.ts:14:21)
webhook_1 | at BackendService. (/usr/src/app/src/backend/backend.service.ts:360:25)
webhook_1 | at Generator.next ()
webhook_1 | at fulfilled (/usr/src/app/src/backend/backend.service.ts:14:58)
webhook_1 | at processTicksAndRejections (internal/process/task_queues.js:97:5) {
```
the stack trace (on kibana) :
```
src/common/graphql/graphql.service.ts in handleErrors at line 22
src/backend/backend.service.ts in BackendService. at line 299
src/backend/backend.service.ts in fulfilled at line 14
internal/process/task_queues.js in processTicksAndRejections at line 97
```
my package.json:
```json
"start:dev": "nodemon",
```
my nodemon.json:
```json
{
"watch": ["src"],
"ext": "ts",
"ignore": ["src/**/*.spec.ts"],
"exec": "ts-node -r tsconfig-paths/register -r source-map-support/register src/main.ts -- --async-stack-traces"
}
```
my tsconfig.json:
```
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./"
},
"exclude": ["node_modules"]
}
```
Contributor guide
Assessment
This issue has not been assessed yet.