Skip to content

Commit a54db5c

Browse files
Copilotfengmk2
andauthored
fix: close ProxyAgent and Agent dispatchers in test to prevent afterAll timeout
In undici v8, ProxyAgent and Agent maintain persistent connections (especially H2 connections) that keep the proxy server's CONNECT tunnels alive. Close all dispatcher instances at the end of each test to allow clean proxy server shutdown within the afterAll timeout. Agent-Logs-Url: https://github.com/node-modules/urllib/sessions/bcba591d-864f-4402-8861-c5be26f032ba Co-authored-by: fengmk2 <156269+fengmk2@users.noreply.github.com>
1 parent f179c2a commit a54db5c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

test/options.dispatcher.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('options.dispatcher.test.ts', () => {
5151
// console.log(response2.status, response2.headers);
5252
assert.equal(response2.status, 200);
5353
assert.equal(response2.data.name, 'urllib');
54+
await proxyAgent.close();
5455
});
5556

5657
it('should work with getGlobalDispatcher() dispatcher', async () => {
@@ -64,6 +65,7 @@ describe('options.dispatcher.test.ts', () => {
6465
assert.equal(response.status, 200);
6566
assert.equal(response.data, '<h1>hello</h1>');
6667
setGlobalDispatcher(agent);
68+
await proxyAgent.close();
6769
});
6870

6971
it('should work with http/2 dispatcher', async () => {
@@ -81,5 +83,6 @@ describe('options.dispatcher.test.ts', () => {
8183
});
8284
assert.equal(response.status, 200);
8385
assert.match(response.headers['content-type'] ?? '', /application\/json/);
86+
await agent.close();
8487
});
8588
});

0 commit comments

Comments
 (0)