diff --git a/test/close-and-destroy.js b/test/close-and-destroy.js index 582bd8cbaba..09998892e57 100644 --- a/test/close-and-destroy.js +++ b/test/close-and-destroy.js @@ -166,6 +166,10 @@ test('close should still reconnect', async (t) => { const client = new Client(`http://localhost:${server.address().port}`) after(() => client.destroy()) + client.once('connect', () => { + client[kSocket].destroy() + }) + t.ok(makeRequest()) t.ok(!makeRequest()) @@ -173,9 +177,6 @@ test('close should still reconnect', async (t) => { t.ifError(err) t.strictEqual(client.closed, true) }) - client.once('connect', () => { - client[kSocket].destroy() - }) function makeRequest () { client.request({ path: '/', method: 'GET' }, (err, data) => {