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 Aug 16, 2017
1 parent 712a953 commit ab443f5
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 ab443f5

Please sign in to comment.