Skip to content

Commit

Permalink
test: fix flaky test-net-can-reset-timeout
Browse files Browse the repository at this point in the history
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 16, 2017
1 parent 95ab966 commit 5d3609d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/parallel/test-net-can-reset-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down

0 comments on commit 5d3609d

Please sign in to comment.