Skip to content

Commit 498238f

Browse files
cjihrigevanlucas
authored andcommitted
test: test sending over a closed IPC channel
This commit adds a test that attempts to send data over an IPC channel once it has been closed. PR-URL: #8160 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com>
1 parent 15bd489 commit 498238f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const cp = require('child_process');
5+
const path = require('path');
6+
const fixture = path.join(common.fixturesDir, 'empty.js');
7+
const child = cp.fork(fixture);
8+
9+
child.on('close', common.mustCall((code, signal) => {
10+
assert.strictEqual(code, 0);
11+
assert.strictEqual(signal, null);
12+
13+
function testError(err) {
14+
assert.strictEqual(err.message, 'channel closed');
15+
}
16+
17+
child.on('error', common.mustCall(testError));
18+
19+
{
20+
const result = child.send('ping');
21+
assert.strictEqual(result, false);
22+
}
23+
24+
{
25+
const result = child.send('pong', common.mustCall(testError));
26+
assert.strictEqual(result, false);
27+
}
28+
}));

0 commit comments

Comments
 (0)