-
Notifications
You must be signed in to change notification settings - Fork 570
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
The line where fetch is called doesn't show in the stack trace #1599
Comments
Yes, it's a undici issue, I moved it there. |
@KhafraDev @ronag have you got some ideas? This would be a true benefit for the ecosystem. |
Doesn't this require some async hook magic? |
I don't think it would. This will get us there: diff --git a/index.js b/index.js
index 8099f5a..0b9a2e5 100644
--- a/index.js
+++ b/index.js
@@ -92,7 +92,12 @@ if (nodeMajor > 16 || (nodeMajor === 16 && nodeMinor >= 8)) {
fetchImpl = require('./lib/fetch')
}
const dispatcher = (arguments[1] && arguments[1].dispatcher) || getGlobalDispatcher()
- return fetchImpl.apply(dispatcher, arguments)
+ try {
+ return await fetchImpl.apply(dispatcher, arguments)
+ } catch (err) {
+ Error.captureStackTrace(err)
+ throw err
+ }
}
module.exports.Headers = require('./lib/fetch/headers').Headers
module.exports.Response = require('./lib/fetch/response').Response I'm not sure the exact implications of this. cc @benjamingr |
This practically adds 2 microticks. |
It is worth paying attention to the second parameter of Error.captureStackTrace(err, this) |
@sosoba would you like to send a PR to implement this? |
Version
v18.7.0
Platform
Linux 98a94d978874 5.4.0-122-generic nodejs/node#138~18.04.1-Ubuntu SMP Fri Jun 24 14:14:03 UTC 2022 x86_64 Linux
Subsystem
fetch
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior?
At some point in the stack frame:
at a (/home/user/projectA/a.js:8:11)
What do you see instead?
Additional information
Maybe undici issue @mcollina ?
The text was updated successfully, but these errors were encountered: