Skip to content

Commit 5f6025b

Browse files
joyeecheungitaloacasas
authored andcommitted
test: fail when child dies in fork-net
Previously when the child dies with errors in this test, the parent will just hang and timeout, the errors in the child would be swallowed. This makes it fail so at least there is more information about why this test fails. Also removes the unnecessary child.kill() call. PR-URL: #11684 Ref: #11667 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 646ee55 commit 5f6025b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/parallel/test-child-process-fork-net.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
require('../common');
2+
const common = require('../common');
33
const assert = require('assert');
44
const fork = require('child_process').fork;
55
const net = require('net');
@@ -60,9 +60,10 @@ if (process.argv[2] === 'child') {
6060

6161
const child = fork(process.argv[1], ['child']);
6262

63-
child.on('exit', function() {
64-
console.log('CHILD: died');
65-
});
63+
child.on('exit', common.mustCall(function(code, signal) {
64+
const message = `CHILD: died with ${code}, ${signal}`;
65+
assert.strictEqual(code, 0, message);
66+
}));
6667

6768
// send net.Server to child and test by connecting
6869
const testServer = function(callback) {
@@ -171,7 +172,6 @@ if (process.argv[2] === 'child') {
171172

172173
testSocket(function() {
173174
socketSuccess = true;
174-
child.kill();
175175
});
176176
});
177177

0 commit comments

Comments
 (0)