timeout and timings are not working?
Describe the bug
- Node.js version: v16.13.1
- OS & version: macOS 12.6
When I send many get requests, timeout and response.timings are not working as expected.
Actual behavior
I send around 500 get requests to different urls concurrently by using promise, timings.dns of each request is increasing.
Expected behavior
timings.dns should show actual time.
Code to reproduce
const got = require("got");
console.time('total');
const urlList = [
"https://devblogs.microsoft.com/landingpage/",
"https://it.impress.co.jp/list/feed/rss",
"https://uxmilk.jp/feed",
... more 500 urls
];
const pList = urlList.map(function(url) {
return got(url, {timeout: {request: 60000, }, retry: {limit: 0}}).then((result) => {
const phases = result.timings.phases;
const paheseResult = [url, phases.wait, phases.dns, phases.tcp, phases.tls, phases.request, phases.firstByte, phases.download, phases.total];
console.log(paheseResult.join(","));
}).catch((e) => {
return null;
});
});
Promise.all(pList).then((result) => {
console.timeEnd('total');
}).catch((e) => {
console.log('error: ' + e);
});
This is the graph which I made from each url's response.timings.
dns is increasing, so if I set timeout to 30s, most of requests fails.
Sorry if this is my misunderstanding because I'm new to node, thanks in advance!
Checklist
- [x] I have read the documentation.
- [x] I have tried my code with the latest version of Node.js and Got.
It's unlikely that the timings are wrong. Can you try https://github.com/sindresorhus/got/blob/main/documentation/2-options.md#dnscache
@szmarczak
Thank you for reply, but it's not changed.
I tried this.
got(url, {timeout: {request: 60000, dnsCache: true}, retry: {limit: 0}})
It looks like some connections are waiting for other connections to finish. Is there any connection limit setting?
You could try passing a custom agent. Also please try HTTP/2