mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
The timeout is unnecessary and the suspected cause of the following
failure (even though I could not reproduce it locally):
11:53:54 not ok 197 parallel/test-pipe-stream
11:53:54 ---
11:53:54 duration_ms: 6.253
11:53:54 severity: fail
11:53:54 exitcode: 1
11:53:54 stack: |-
11:53:54 assert.js:338
11:53:54 throw err;
11:53:54 ^
11:53:54
11:53:54 AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
11:53:54
11:53:54 assert.ok(have_ping)
11:53:54
11:53:54 at check (/home/iojs/build/workspace/node-test-binary-arm/test/parallel/test-pipe-stream.js:14:12)
11:53:54 at Server.<anonymous> (/home/iojs/build/workspace/node-test-binary-arm/test/parallel/test-pipe-stream.js:61:5)
11:53:54 at Server.emit (events.js:182:13)
11:53:54 at emitCloseNT (net.js:1668:8)
11:53:54 at process._tickCallback (internal/process/next_tick.js:63:19)
(From https://ci.nodejs.org/job/node-test-binary-arm/2235/RUN_SUBSET=5,label=pi3-docker/console.)
PR-URL: https://github.com/nodejs/node/pull/21837
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
64 lines
1.2 KiB
JavaScript
64 lines
1.2 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
function test(clazz, cb) {
|
|
let have_ping = false;
|
|
let have_pong = false;
|
|
|
|
function check() {
|
|
assert.ok(have_ping);
|
|
assert.ok(have_pong);
|
|
}
|
|
|
|
function ping() {
|
|
const conn = new clazz();
|
|
|
|
conn.on('error', function(err) {
|
|
throw err;
|
|
});
|
|
|
|
conn.connect(common.PIPE, function() {
|
|
conn.write('PING', 'utf-8');
|
|
});
|
|
|
|
conn.on('data', function(data) {
|
|
assert.strictEqual(data.toString(), 'PONG');
|
|
have_pong = true;
|
|
conn.destroy();
|
|
});
|
|
}
|
|
|
|
function pong(conn) {
|
|
conn.on('error', function(err) {
|
|
throw err;
|
|
});
|
|
|
|
conn.on('data', function(data) {
|
|
assert.strictEqual(data.toString(), 'PING');
|
|
have_ping = true;
|
|
conn.write('PONG', 'utf-8');
|
|
});
|
|
|
|
conn.on('close', function() {
|
|
server.close();
|
|
});
|
|
}
|
|
|
|
const server = net.Server();
|
|
server.listen(common.PIPE, ping);
|
|
server.on('connection', pong);
|
|
server.on('close', function() {
|
|
check();
|
|
cb && cb();
|
|
});
|
|
}
|
|
|
|
test(net.Stream, function() {
|
|
test(net.Socket);
|
|
});
|