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 authored and MylesBorins committed Sep 5, 2017
1 parent 95be08e commit 1e40390
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
@@ -1,13 +1,16 @@
'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 1e40390

Please sign in to comment.