Skip to content

Commit

Permalink
Fix a timeout test for Node.js 13.x
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Apr 12, 2020
1 parent 742eb54 commit 48b817e
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions test/timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,21 +522,16 @@ test.serial('socket timeout is canceled on error', withServerAndLolex, async (t,
test.serial('no memory leak when using socket timeout and keepalive agent', withServerAndLolex, async (t, server, got, clock) => {
server.get('/', defaultHandler(clock));

const promise = got({
let request: any;

await got({
agent: {http: keepAliveAgent},
timeout: {socket: requestDelay * 2}
}).on('request', _request => {
request = _request;
});

let socket!: net.Socket;
promise.on('request', (request: http.ClientRequest) => {
request.on('socket', () => {
socket = request.socket;
});
});

await promise;

t.is(socket.listenerCount('timeout'), 0);
t.is(request.timeoutCb, null);

keepAliveAgent.destroy();
});
Expand Down

0 comments on commit 48b817e

Please sign in to comment.