Permalink
Browse files

test: fix flaky test-net-can-reset-timeout

Use `.once()` rather than `.on()` for timeout listener.

Add comment with URL for issue explaining the purpose of the test. (h/t
refack)

PR-URL: #14257
Fixes: #14241
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
  • Loading branch information...
Trott committed Jul 15, 2017
1 parent 95ab966 commit 5d3609dbdd98b3ea3c53a3020305b7567979c888
Showing with 4 additions and 1 deletion.
  1. +4 −1 test/parallel/test-net-can-reset-timeout.js
@@ -21,14 +21,17 @@
'use strict';
const common = require('../common');
// Ref: https://github.com/nodejs/node-v0.x-archive/issues/481
const net = require('net');
const server = net.createServer(common.mustCall(function(stream) {
stream.setTimeout(100);
stream.resume();
stream.on('timeout', common.mustCall(function() {
stream.once('timeout', common.mustCall(function() {
console.log('timeout');
// try to reset the timeout.
stream.write('WHAT.');

0 comments on commit 5d3609d

Please sign in to comment.