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: https://github.com/nodejs/node/pull/14257 Fixes: https://github.com/nodejs/node/issues/14241 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
This commit is contained in:
parent
95ab966a74
commit
5d3609dbdd
@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
|
// Ref: https://github.com/nodejs/node-v0.x-archive/issues/481
|
||||||
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
|
||||||
const server = net.createServer(common.mustCall(function(stream) {
|
const server = net.createServer(common.mustCall(function(stream) {
|
||||||
@ -28,7 +31,7 @@ const server = net.createServer(common.mustCall(function(stream) {
|
|||||||
|
|
||||||
stream.resume();
|
stream.resume();
|
||||||
|
|
||||||
stream.on('timeout', common.mustCall(function() {
|
stream.once('timeout', common.mustCall(function() {
|
||||||
console.log('timeout');
|
console.log('timeout');
|
||||||
// try to reset the timeout.
|
// try to reset the timeout.
|
||||||
stream.write('WHAT.');
|
stream.write('WHAT.');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user