got: Async stack traces for callback errors
What problem are you trying to solve?
I need to know the caller that generated a given http error.
Describe the feature
I use node 13 which has async stack traces but I don’t have the caller stack trace when using got. Instead I get this stack:
err HTTPError: Response code 404 (Not Found)
at EventEmitter.<anonymous> (.../node_modules/got/dist/
source/as-promise.js:118:31)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
name: 'HTTPError'
}
I guess this happens because the connection can be used by multiple callers but there should be a way to have the whole stack.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 23 (3 by maintainers)
async_hooks
is now [almost] stable >=13.10.0 https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V13.md/#notable-changes-1Could we use
async_hooks
somehow to improve the stack traces?Also in case it’s helpful to any future readers using TypeScript, here’s my working TypeScript version
Adding the
source
property to the error object was causing issues so I just decided to append to the existing stack.https://github.com/sindresorhus/got/blob/main/documentation/async-stack-traces.md#conclusion
@szmarczak thank you for crafting this document!
We could, but:
I think we should create another
.md
file and show how to achieve the desired result step-by-step.