Skip to content

Commit a605b23

Browse files
authored
Updated according to @abdurriq feedback
1 parent c1a0d97 commit a605b23

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/spec-utils/httpRequest.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export async function request(options: { type: string; url: string; headers: Rec
2323
headers: options.headers,
2424
agent: new ProxyAgent(),
2525
secureContext,
26+
timeout: 3000
2627
};
2728

2829
const plainHTTP = parsed.protocol === 'http:' || parsed.hostname === 'localhost';
@@ -40,8 +41,9 @@ export async function request(options: { type: string; url: string; headers: Rec
4041
res.on('data', chunk => chunks.push(chunk as Buffer));
4142
res.on('end', () => resolve(Buffer.concat(chunks)));
4243
}
43-
}).setTimeout(2000, () => {
44-
req.end();
44+
});
45+
req.on('timeout', () => {
46+
req.destroy();
4547
});
4648
req.on('error', reject);
4749
if (options.data) {

0 commit comments

Comments
 (0)