Skip to content

Commit 5254975

Browse files
committed
test: refactor test-net-GH-5504
* Improve comments describing test. * Remove unnecessary `common.noop` * Remove confusing scoping of `c` identifier PR-URL: #13025 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 658741b commit 5254975

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

test/sequential/test-net-GH-5504.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
'use strict';
2323
const common = require('../common');
2424

25-
// this test only fails with CentOS 6.3 using kernel version 2.6.32
26-
// On other linuxes and darwin, the `read` call gets an ECONNRESET in
25+
// Ref: https://github.com/nodejs/node-v0.x-archive/issues/5504
26+
//
27+
// This test only fails with CentOS 6.3 using kernel version 2.6.32.
28+
// On other Linuxes and macOS, the `read` call gets an ECONNRESET in
2729
// that case. On sunos, the `write` call fails with EPIPE.
2830
//
29-
// However, old CentOS will occasionally send an EOF instead of a
31+
// However, old CentOS will occasionally send an EOF instead of an
3032
// ECONNRESET or EPIPE when the client has been destroyed abruptly.
3133
//
3234
// Make sure we don't keep trying to write or read more in that case.
@@ -74,25 +76,24 @@ function parent() {
7476
NODE_DEBUG: 'net'
7577
})
7678
});
77-
let c;
7879

7980
wrap(s.stderr, process.stderr, 'SERVER 2>');
8081
wrap(s.stdout, process.stdout, 'SERVER 1>');
81-
s.on('exit', common.mustCall(common.noop));
82+
s.on('exit', common.mustCall());
8283

8384
s.stdout.once('data', common.mustCall(function() {
84-
c = spawn(node, [__filename, 'client']);
85+
const c = spawn(node, [__filename, 'client']);
8586
wrap(c.stderr, process.stderr, 'CLIENT 2>');
8687
wrap(c.stdout, process.stdout, 'CLIENT 1>');
87-
c.on('exit', common.mustCall(common.noop));
88+
c.on('exit', common.mustCall());
8889
}));
8990

9091
function wrap(inp, out, w) {
9192
inp.setEncoding('utf8');
92-
inp.on('data', function(c) {
93-
c = c.trim();
94-
if (!c) return;
95-
out.write(`${w}${c.split('\n').join(`\n${w}`)}\n`);
93+
inp.on('data', function(chunk) {
94+
chunk = chunk.trim();
95+
if (!chunk) return;
96+
out.write(`${w}${chunk.split('\n').join(`\n${w}`)}\n`);
9697
});
9798
}
9899
}

0 commit comments

Comments
 (0)