-
Notifications
You must be signed in to change notification settings - Fork 575
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
fetch error loses stack context #2331
Comments
Shall we remove the |
yes probably, although it was added on purpose to show where the error originated from |
if we remove it the stack trace doesn't contain where fetch was called from, probably not much we can do here? |
It has it, isn't it? at CompatFinalizer.register (/var/github/undici/lib/compat/dispatcher-weakref.js:25:16)
at new Request (/var/github/undici/lib/fetch/request.js:391:26)
at fetch (/var/github/undici/lib/fetch/index.js:136:21)
at fetch (/var/github/undici/index.js:107:20)
at file:///var/github/undici/test.mjs:5:7 It is more verbose, sure but at least it won't point directly to the |
with this code: import { fetch } from './index.js'
await fetch('https://a')
with:
notice that the "with" stack trace includes the file fetch was called from, |
Ah, ok now I see; within the Playing a bit, I think we can have a quick workaround, but replacing the With +node:internal/process/task_queues:95
runMicrotasks();
^
TypeError: fetch failed
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///var/users/github/undici/playground.mjs:28:1 {
cause: Error: getaddrinfo ENOTFOUND a
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'a'
}
} With +/Users/metcoder/Documents/Workspace/MetCoder/Undici_Core/index.js:113
Error.captureStackTrace(err, this)
^
TypeError: fetch failed
at fetch (/Users/metcoder/Documents/Workspace/MetCoder/Undici_Core/index.js:113:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///Users/metcoder/Documents/Workspace/MetCoder/Undici_Core/playground.mjs:28:1 {
cause: Error: getaddrinfo ENOTFOUND a
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'a'
}
} I imagine the execution context and how |
The original "fix" was in #1619, where diff was - return fetchImpl.apply(dispatcher, arguments)
+ try {
+ return await fetchImpl.apply(dispatcher, arguments)
+ } catch (err) {
+ Error.captureStackTrace(err, this)
+ throw err
+ } this changes two things:
Could we revert the second part? That should gives us a stack trace from the broken internals of undici all the way up to user code. |
@KhafraDev @metcoder95 was there any progress with thisv |
Not really, I haven't dig deeper after that I showed; once done with the other opened PRs I might be able to revisit this. Stills open if anyone wants to give it a try 👍 |
It does not, the original issue then pops up again. |
will this ever be resolved? i just encountered this and there is literally no origin of the actual source |
I'm 100% lost on the reproduction for this. Can somebody add one? |
repro from #2328
without the Error.captureStackTrace in index.js:
with:
The text was updated successfully, but these errors were encountered: