You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fetch fails with internal error after 5 minutes #46375
@bnoordhuis , thank you for the response
For me this behaviour was unexpected, becaues in browser (chrome) there is no timeout (or at least its very big, because my requests succesfully wait for response more than 10 minutes).
Ok, lets say in nodejs fetch method has default timeout (5min). Is it possible to change (increase) it? I will be grateful for any hints/examples.
This should absolutely be documented, given the current expectation of node's native fetch implementation being a swap-in replacement for the browser implementation. I just ran into this issue while building an AWS Lambda extension layer, which requires a long-running network request that only responds when the function is next invoked. This may sometimes require the request to remain open for longer than 5 minutes between invocations.
I understand these timeouts are configured by the underlying undici implementation - which itself is currently causing a concerning level of turbulence in the global fetch API, for example: #46706
It's unfortunate that configureable timeouts were not considered when shipping global.fetch
Reacted by oleksii-korpan, Justin Dalrymple, Martin Kase, Rich Robinson, volk234, Alberto Diaz Dorado, Maxim Stykow, Praveen Pendyala, Reece, Sashok and 2 more
I am having a similar issue. I have a node server running with nodemon. If the laptop, running windows, is closed while the nodemon server is running. After waiting a while and the opening the latptop again, then this issue appears. Restarting the laptop fixes the problem.
To anyone who still encounters the issue even though they don't use any VPN's or Firewall, try to change your DNS to use Manual. I change mine to : Preferred DNS server: 8.8.8.8 Alternate DNS server: 8.8.4.4
and I can use fetch or undici library with no timeout or fetch failed issues.
@mcollina@bnoordhuis the way this seems to be handled according to MDN is with timeout/abort signals is there a reason that node chose to diverge from that standard?
Undici clearly seems capable of waiting forever if configured correctly? Is this same configuration possible without a direct dependency on undici?
I want to kindly request to re-open this issue as I don't believe it is resolved.
Working as intended, not a bug. I'll close this but I can convert it to a conversation if you have follow-up questions.
According to previous comments, there is a hard coded limitation of 5min for Node.js native fetch function. Apparently this can be changed in the underlying implementation. There is furthermore no clear documentation that Node.js's native fetch deviates from other JavaScript runtimes when it comes to this timeout.
I would like to highlight my issue with this: we are using native fetch in WebdriverIO where we make requests to initiate automate mobile sessions using Appium. It sometimes takes longer than 5min to setup the phone correctly and allow automation on it. We have received an issue for this here: webdriverio/webdriverio#13783
The amount of linked issues clearly shows that folks have issues with this situation. Is there any contribution I can make to resolve this? I am happy to jump into the code if the team believes that just increasing this timeout would be a good approach.
Reacted by Boris Osipov, Aasmund Gabestad Nørsett, Fabien Deborde, Na'aman Hirschfeld, Gianfranco Frau, k257588376, DivisionByZero, Jack Vandemeulebroecke, Jarno, Daniel Muñoz and 1 more
"Working As Intended" is an annoying way of saying that you're too lazy to fix something that should be configurable, instead of hard coded. And, that's just annoying.
In case you're wondering, I am here because a web application that I run locally uses the "fetch" code... and it times out before the API call can complete.
I (too) am in favor of reopening this (maybe as a feature request?) and having the change implemented.
I'll skip all of the questions and facepalming that I have over why this is hard coded... And I will simply offer the advice of: "If you think that they won't mind -- change it, because they will mind. If you think that it's longer than you'll ever need, remember that Bill Gates once said that 640k of memory is more than anyone will ever need... and look where that got him."
So, there's my words of wisdom for the day... Please, can this be reopened and properly classified so that it becomes part of someone's to-do list?
Thank you!
Reacted by Gianfranco Frau, ido-wolf-moonactive, Elizabeth Manrique, Daniel Muñoz and Julian Andres Rojas Melendez
xd, after running multiple tests assuming it's my ingress controller causing the problem, I find a thread saying nodejs is enforcing default timeouts?!
Activity
bnoordhuis commentedon Jan 27, 2023
It says so why in the error message:
UND_ERR_HEADERS_TIMEOUTa.k.a. timed out while waiting for response headers.Working as intended, not a bug. I'll close this but I can convert it to a conversation if you have follow-up questions.
oleksii-korpan commentedon Jan 27, 2023
@bnoordhuis , thank you for the response
For me this behaviour was unexpected, becaues in browser (chrome) there is no timeout (or at least its very big, because my requests succesfully wait for response more than 10 minutes).
Ok, lets say in nodejs
fetchmethod has default timeout (5min). Is it possible to change (increase) it? I will be grateful for any hints/examples.bnoordhuis commentedon Jan 27, 2023
I think for fetch() the answer is "no" but node's own
http.get()has configurable timeouts.mattfysh commentedon Mar 27, 2023
This should absolutely be documented, given the current expectation of node's native fetch implementation being a swap-in replacement for the browser implementation. I just ran into this issue while building an AWS Lambda extension layer, which requires a long-running network request that only responds when the function is next invoked. This may sometimes require the request to remain open for longer than 5 minutes between invocations.
I understand these timeouts are configured by the underlying undici implementation - which itself is currently causing a concerning level of turbulence in the global fetch API, for example: #46706
It's unfortunate that configureable timeouts were not considered when shipping global.fetch
cc @mcollina
bnoordhuis commentedon Mar 27, 2023
fetch() is a standard. The standard doesn't say anything about timeouts. It's up to implementers to pick reasonable defaults.
If you want more control, use node's own http client.
mcollina commentedon Mar 27, 2023
Configuring a custom agent in undici will allow to change these defaults.
mattfysh commentedon Mar 27, 2023
@mcollina can this be done natively? I reviewed this test and the Agent appears to be incompatible with node's native agents: https://github.com/nodejs/undici/blob/7827031d2a7fd99f8ab9d5eddce127c6f700dd35/test/fetch/fetch-timeouts.js
AasmundN commentedon May 19, 2023
I am having a similar issue. I have a node server running with nodemon. If the laptop, running windows, is closed while the nodemon server is running. After waiting a while and the opening the latptop again, then this issue appears. Restarting the laptop fixes the problem.
tonskton commentedon Mar 12, 2024
To anyone who still encounters the issue even though they don't use any VPN's or Firewall, try to change your DNS to use Manual. I change mine to :
Preferred DNS server: 8.8.8.8
Alternate DNS server: 8.8.4.4
and I can use fetch or undici library with no timeout or fetch failed issues.
evgenyfedorchenko commentedon Apr 9, 2024
Thanks, you saved my life. i have used
http.request, and it also worked correctly with 1h timeoutconst makeHttpRequest = (options, postData) =>
new Promise((resolve, reject) => {
const req = http.request(options, (res) => {
let data = "";
});
clayreimann commentedon Oct 8, 2024
@mcollina @bnoordhuis the way this seems to be handled according to MDN is with timeout/abort signals is there a reason that node chose to diverge from that standard?
Undici clearly seems capable of waiting forever if configured correctly? Is this same configuration possible without a direct dependency on undici?
In my particular case looker's sdk handles the configuration for node's fetch so I don't have a direct way to configure this even if that's possible.
christian-bromann commentedon Oct 24, 2024
I want to kindly request to re-open this issue as I don't believe it is resolved.
According to previous comments, there is a hard coded limitation of 5min for Node.js native
fetchfunction. Apparently this can be changed in the underlying implementation. There is furthermore no clear documentation that Node.js's native fetch deviates from other JavaScript runtimes when it comes to this timeout.I would like to highlight my issue with this: we are using native fetch in WebdriverIO where we make requests to initiate automate mobile sessions using Appium. It sometimes takes longer than 5min to setup the phone correctly and allow automation on it. We have received an issue for this here: webdriverio/webdriverio#13783
The amount of linked issues clearly shows that folks have issues with this situation. Is there any contribution I can make to resolve this? I am happy to jump into the code if the team believes that just increasing this timeout would be a good approach.
michieal commentedon Dec 18, 2024
"Working As Intended" is an annoying way of saying that you're too lazy to fix something that should be configurable, instead of hard coded. And, that's just annoying.
In case you're wondering, I am here because a web application that I run locally uses the "fetch" code... and it times out before the API call can complete.
I (too) am in favor of reopening this (maybe as a feature request?) and having the change implemented.
I'll skip all of the questions and facepalming that I have over why this is hard coded... And I will simply offer the advice of: "If you think that they won't mind -- change it, because they will mind. If you think that it's longer than you'll ever need, remember that Bill Gates once said that 640k of memory is more than anyone will ever need... and look where that got him."
So, there's my words of wisdom for the day... Please, can this be reopened and properly classified so that it becomes part of someone's to-do list?
Thank you!
narengogi commentedon Jun 6, 2025
xd, after running multiple tests assuming it's my ingress controller causing the problem, I find a thread saying nodejs is enforcing default timeouts?!
Add Undici dispatcher to disable hidden 5-min timeouts
Fix undici 5-minute timeout: set headersTimeout and bodyTimeout to 30min