-
Notifications
You must be signed in to change notification settings - Fork 541
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
Opaque, undebuggable stacktraces #2212
Comments
This also happens when the fetch fails in general. |
I don't understand why that line is undebuggable: it seems pretty clear to me. Is the problem the missing reference to where the call to fetch initiated? I think this is due to the fact that we are not using the |
it's because we use queueMicrotask here Line 821 in c83b084
|
Sorry for the lack of clarity here. The lack of stacktrace is the issue. In a code-base with more than a few fetches, it becomes impossible to tell where the failed fetch occurred since it just gives the error and says nothing about where it originated in the code. This does not happen with node-fetch, regardless of whether I use |
@KhafraDev I think we should be doing something for this, I think it can be very problematic for people. |
do you have any ideas? The queueMicrotask is needed for the spec (as close as a match we can get in node). |
you'd need to turn Line 815 in c83b084
await readAllBytes . Then inside you'd need to await all those things. If you want to add a microtick, just doing await true would get you there (or await Promise.resolve() , then do await processBody(bytes)
|
* better stack trace for body.json Fixes #2212 * not needed * nit
* better stack trace for body.json Fixes nodejs#2212 * not needed * nit
Bug Description
When calling
await r.json()
, if the request text was not valid JSON, undici returns an opaque stacktrace which does not go to the line where the error was happening. This makes debugging near impossible.Reproducible By
Write a fetch to an endpoint that does not return valid JSON. Then, call
fetch("/endpoint").then(r => r.json())
Expected Behavior
An error thrown on the line where
await request.json()
was called.Logs & Screenshots
Current behavior:
Environment
Node 20
The text was updated successfully, but these errors were encountered: