-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Labels
Description
i don't know enough about the fetch spec to say if this is a bug or not but it's definitely not what i expected.
this code below causes 10 separate connections. i'd expect what to happen in this situation is the first request blocks the others until the connection is established and they all share it.
additionally, this causes something to be off with a stuck reference or something. "complete" is printed but the process never exits.
const { fetch, disconnectAll } = require('fetch-h2');
const urls = [
'https://example.com/api/1',
'https://example.com/api/2',
'https://example.com/api/3',
'https://example.com/api/4',
'https://example.com/api/5',
'https://example.com/api/6',
'https://example.com/api/7',
'https://example.com/api/9',
'https://example.com/api/10',
];
const main = async () => {
const results = await Promise.all(urls.map(async url => {
const res = await fetch(url);
const body = await res.text();
return body;
}));
await disconnectAll();
return 'complete';
};
main().then(console.log);blocking with an initial call fixes issue:
const main = async () => {
await fetch('https://example.com/');
const results = await Promise.all(...That results in just one connection being used and the process exiting as expected. It seems related to getOrCreateHttp2 but not sure. 😪 🛏
Reactions are currently unavailable