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
I'm using the following code to make a large number of GET requests to a URL, for convenience I'm repeating the request to a URL and I've found that when the number of requests exceeds a certain value it causes most of the requests to timeout.
When I set count to 100 there is no error output from the console, but when I set count to a larger value most of the requests return a timeout error, for example if I set count to 500 over 400 of them all timeout.
constfetch=require('node-fetch')consturl='https://cdn.jsdelivr.net/npm/twikoo@1.6.17/dist/twikoo.all.min.js'constlist=[]constcount=500leterrCount=0for(leti=0;i!==count;++i){conststartTime=newDate().getTime()constid=iconsttask=fetch(url,{timeout: 5000}).catch(err=>{++errCountconstendTime=newDate().getTime()console.error(`fail ${id}: use time = ${endTime-startTime}, message = ${err}`)})list.push(task)}Promise.all(list).then(()=>{console.log(`finish errCount = ${errCount}`)})
Expected behavior
I suspect this is because node-fetch provides a queuing sequence to cope with high concurrency, but the timeout timer still starts when a request is queued.
If I'm right, would it be possible to provide an option to allow the timeout to start when the request actually starts? Or is it possible to provide an interface that allows the user to customise this behaviour?
Your Environment
software
version
node-fetch
2.6.12
node
18.12.1
npm
9.8.1
Operating System
windows 10
The text was updated successfully, but these errors were encountered:
Reproduction
I'm using the following code to make a large number of GET requests to a URL, for convenience I'm repeating the request to a URL and I've found that when the number of requests exceeds a certain value it causes most of the requests to timeout.
When I set
count
to100
there is no error output from the console, but when I setcount
to a larger value most of the requests return a timeout error, for example if I setcount
to500
over 400 of them all timeout.Expected behavior
I suspect this is because
node-fetch
provides a queuing sequence to cope with high concurrency, but the timeout timer still starts when a request is queued.If I'm right, would it be possible to provide an option to allow the timeout to start when the request actually starts? Or is it possible to provide an interface that allows the user to customise this behaviour?
Your Environment
The text was updated successfully, but these errors were encountered: