From 48b817ee6bfbd32d66f10c4b0dcf6af378fd2313 Mon Sep 17 00:00:00 2001 From: Szymon Marczak <36894700+szmarczak@users.noreply.github.com> Date: Sun, 12 Apr 2020 16:23:12 +0200 Subject: [PATCH] Fix a timeout test for Node.js 13.x --- test/timeout.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/test/timeout.ts b/test/timeout.ts index 33992659c..cd71830d9 100644 --- a/test/timeout.ts +++ b/test/timeout.ts @@ -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(); });