Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Async stack traces for callback errors #1077
Comments
|
This works as expected: |
|
Related: #795 |
|
I don't think we can do much about this. This is just how Node.js works. One possible solution would be to create a stacktrace before making the request and create another one when erroring and then merge these two. @sindresorhus What do you think? |
|
Could we use |
|
We could, but:
I think we should create another |
@szmarczak This approach works. Our team used in many projects that involved multiplexing a connection or a event emitter. The only think I would worry about is the CPU load associated with generating the stack. Maybe stack trace generation performance has improved in the last years. I have seen some articles talking about zero cost async stack traces but I'm not sure if it applies: |
|
@aalexgabi The zero-cost stacktraces you mentioned are related to async/await (and are already on by default), not I/O operations. |
Yeah, we cannot modify anything globally. But would it have to be global? I was thinking of storing the stack in the async context and then merge it on error.
|
That would work too, but the question is how much performance you would have to give up, since on every async task there would be called |
|
Maybe we should just make an independent module that creates long stack traces using async hooks contexts and then recommend that, but warn that it might have a performance impact. Then the user can decide whether it's worth it or not. |
|
|
|
Would the |
|
@PSeitz It's already on by default IIRC. |
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:
I guess this happens because the connection can be used by multiple callers but there should be a way to have the whole stack.