-
Notifications
You must be signed in to change notification settings - Fork 572
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
TypeError: fetch failed #1248
Comments
Thanks for reporting, would you like to include a code to reproduce your problem? We'd also need the server counterpart. |
@mcollina We cannot share production environment credentials, but we could give you sandbox credentials via remote desktop. Is there any other way to give you more info for debugging? |
I think it would be better if you produced a server that returned that kind of response. We do not provide support for private code. |
Matteo, the server is NetSuite ERP, so we cannot provide it. Also note we've replaced undici fetch with We can provide you with isolated fetch request, no code required. But we cannot share the credentials to run this request. |
There is something in that server response that it is making undici.fetch fail. What I'm asking is a way to reproduce this without touching your systems. Only you can write it. |
Right but I don't understand how? The only way we can reproduce it ourselves is by executing that request to that account with those credentials. |
There's supposed to be an additional |
@Linkgoron No. The code is like this. But 2nd line is never reached.
|
Sorry but with this little information it's impossible for us to do anything. |
@ronag So I'm trying to get you more information. Can we add some debugging code in undici to help you diagnose it? |
I also get some error, it's not the same:
|
Maybe this can help? I am experiencing the same with a Firebase Emulators host.
In one terminal:
In another:
Added: Once
Trying with
|
As a continuation to my above report, from a CI run. It looks like Undici (4.14.1)
|
I don't think this has anything to do with undici per se. Does it work with the normal |
It works with Got some more light to why My
If I comment out the line |
@akauppi: Sorry but I don't think this is an issue we can resolve in undici. Sounds more like a node core dns thing. I suggest you open an issue in the node repo. |
@ronag emailed you |
@ronag I'm still having these errors. Cannot use undici fetch at all. Here is updated trace from Node v18:
@ronag Could you re-open or reply to my emails? |
Had the same issue, had to switch from node v18 to v16 as a temp workaround. |
This worked for me. Also was having the same issue without any resolution and downgrading to |
We also keep getting this error from time to time in Node.js 18.7.0 |
I think I know what the problem is. In node v17 we switched the default ordering of dns entries to follow what the OS is providing us vs reordering to put ipv4 always first. I think we should try multiple addresses when dealing with localhost when establishing a new connection. Wdyt @ronag? |
SGTM! |
I removed the line |
It's not related to localhost in many cases. |
Im not sure why but seems the team decided to ignore this bug ? Any news about this issue |
No one has provide a repro for them to look into |
@kyrylkov ok tested this on v20.4.0 I think its fixed for now can't say for sure |
We have this issue with v20.4.0 also |
I did the same. I replaced "localhost" with "127.0.0.1" 👎🏻 |
Having the same issue, downgrading to 18.16.0 solved it. |
The problem with the debugging is that new Error("", { cause: new Error() }).stack Error
at [eval]:1:13
at Script.runInThisContext (node:vm:128:12)
at Object.runInThisContext (node:vm:306:38)
at node:internal/process/execution:83:21
at [eval]-wrapper:6:24
at runScript (node:internal/process/execution:82:62)
at evalScript (node:internal/process/execution:104:10)
at node:internal/main/eval_string:50:3 Whereas util.inspect(new Error("", { cause: new Error() })) Error
at [eval]:1:37
at Script.runInThisContext (node:vm:128:12)
... 5 lines matching cause stack trace ...
at node:internal/main/eval_string:50:3 {
[cause]: Error
at [eval]:1:60
at Script.runInThisContext (node:vm:128:12)
at Object.runInThisContext (node:vm:306:38)
at node:internal/process/execution:83:21
at [eval]-wrapper:6:24
at runScript (node:internal/process/execution:82:62)
at evalScript (node:internal/process/execution:104:10)
at node:internal/main/eval_string:50:3 That You'll need to fix the logging to include the cause, not just the stack. |
@pauldraper You're right about the cause. But disregarding whether logging includes the cause or not, there is clearly something wrong with various versions of undici / Node.js. Because with some combinations of undici / Node.js versions |
Well, that's actually pretty significant. I suggest posting the cause. |
It is significant, but even more significant is the repro, which no one could produce so far because the issue is intermittent and not easily reproducible. In our case, for example, when it fails, it fails in like 1 request out of 1000. And as soon as we log the request and retry it, it works just fine without producing the error. |
It could be, for example, a network failure. No way to know here. |
It can be, but it is not. Why? Because it happens only with a certain combination of Node / undici. And it doesn't happen at all with other combinations. Thus it is a Node / undici issue. And we are talking about sampling periods of weeks here. |
This happened to me a few hours ago. I logged the cause. cause: HeadersTimeoutError: Headers Timeout Error |
I don't think it's a network failure. On SvelteKit (which is where I got this error), once it happens once it keeps on happening multiple times (even if I restart node) and then just randomly decides to start working again. I also thought it could have been a network issue but everything else worked perfectly... edit: typo |
That happens when the server hasn't replied with anything in a minute or so. |
I think some of these issue might be related to keep-alive + server or client bugs. Try to disable keep-alive and see if the issue persists. |
For unidici fetch, at one time, |
Fwiw my report wasn't timeout related as the error was instantaneous in all cases. |
I am facing an issue while sending a GET request with body data. The error disappears when I remove the body data. But when I send a POST request with a body, the error doesn't occur. My current version of Next.js is 13.4, and I suspect that the error is caused by trying to send a GET request with body data. |
@arun1940 We had it both with GET without body and with many POSTs. |
Try it check with node-fetch, import this import fetch from 'node-fetch'; |
I managed to resolve my issue by removing the data from the body of the GET request. I was using Postman to test my API and my application is built on Next.js version 13.4. The error that was occurring has been resolved.- error Failed to handle a request for /api/xxx-xx |
@gigantino We're you able to resolve this within SvelteKit? I'm facing the same issue trying to access a certain LinkedIn endpoint (others work fine). Exact same behaviour. Randomly works sometimes when I'm not looking. |
@0oj I did by switching to Node 18.16.0 |
Hello, anyone got the fix to this error? |
This issue is happening in @microsoft/signalr |
This is a generic error that can occur due to several different reasons. Please check the cause property on the error. |
Bug Description
Fetch throws 'TypeError: fetch failed' when posting
Reproducible By
Request with private production credentials to ERP
Expected Behavior
Successful response (ok).
node-fetch
works just fine.Logs & Screenshots
Environment
Linux and Windows, v17.5 v17.6
Additional context
Request takes up to several minutes until response
The text was updated successfully, but these errors were encountered: