Simultaneous fetches over 6 are being dropped instead of being queued.

Hi.
I'm doing multiple Http calls to external server via fetch(). It works locally. But anything over 6 on deployed version throws error instantly. Docs say that additional fetches should be automatically queued and executed when older ones get freed up.
4 Replies
kian
kian9mo ago
What's the error you're getting?
K
KOP9mo ago
"Response closed due to connection limit"
kian
kian9mo ago
How many calls are you making?
K
KOP8mo ago
I've tested with 7, 10 and 30. Even with 7 it throws error. I'm still interested in having this solved I found out that the error happens when trying to resolve fetches in Promise.all() So with this code:
let promises=[];
let results=[]
for (let i =0;i<10;i++){
let url = new URL("https://echo.free.beeceptor.com/")
promises.push(fetch(url, {cf:{cacheEverything: false,cacheTtl:0}}))

}
let promises=[];
let results=[]
for (let i =0;i<10;i++){
let url = new URL("https://echo.free.beeceptor.com/")
promises.push(fetch(url, {cf:{cacheEverything: false,cacheTtl:0}}))

}
this won't work: await Promise.all(promises).then(results2=>{results = results2}) but this code below works
await Promise.all(
promises.map(
async (task)=>{
await task.then(
async (r)=>{
results.push(await r.json() )
})
})
)
console.log(results)
await Promise.all(
promises.map(
async (task)=>{
await task.then(
async (r)=>{
results.push(await r.json() )
})
})
)
console.log(results)
Judging by time it takes working code to resolve, it seems to be doing 6 fetches concurrently. I think it might be error in how worker parses code for queing. And promise.all seems to be omitted.
Want results from more Discord servers?
Add your server