Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnatoli Papirovski <apapirovski@mac.com>2017-10-25 16:26:20 +0300
committercjihrig <cjihrig@gmail.com>2017-10-25 22:33:45 +0300
commitbf02780fd159a65ab96ccf9d65f97da6d65908bc (patch)
tree2f7494ed0acd44ef83d01aa5d7d6c8878cff8bc8 /test
parentd66c9276a976b4177e56634a5707d43d0e56603e (diff)
net: fix timeout with null handle
This commit handles the case where _onTimeout is called with a null handle. Refs: https://github.com/nodejs/node/pull/15791 Fixes: https://github.com/nodejs/node/issues/16484 PR-URL: https://github.com/nodejs/node/pull/16489 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-net-timeout-no-handle.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/parallel/test-net-timeout-no-handle.js b/test/parallel/test-net-timeout-no-handle.js
new file mode 100644
index 00000000000..539f661cae8
--- /dev/null
+++ b/test/parallel/test-net-timeout-no-handle.js
@@ -0,0 +1,17 @@
+'use strict';
+
+const common = require('../common');
+const net = require('net');
+const assert = require('assert');
+
+const socket = new net.Socket();
+socket.setTimeout(common.platformTimeout(50));
+
+socket.on('timeout', common.mustCall(() => {
+ assert.strictEqual(socket._handle, null);
+}));
+
+socket.on('connect', common.mustNotCall());
+
+// since the timeout is unrefed, the code will exit without this
+setTimeout(() => {}, common.platformTimeout(200));