diff --git a/test/parallel/test-child-process-fork-net.js b/test/parallel/test-child-process-fork-net.js index 0760ca44adc3c7..bf19a2bdd152d9 100644 --- a/test/parallel/test-child-process-fork-net.js +++ b/test/parallel/test-child-process-fork-net.js @@ -19,6 +19,9 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. +// This tests that a socket sent to the forked process works. +// See https://github.com/nodejs/node/commit/dceebbfa + 'use strict'; const { mustCall, @@ -65,7 +68,7 @@ if (process.argv[2] === 'child') { socket.on('finish', mustCall(() => { debug(`[${id}] socket finished ${m}`); })); - })); + }, 4)); process.on('message', mustCall((m) => { if (m !== 'close') return; @@ -74,7 +77,7 @@ if (process.argv[2] === 'child') { debug(`[${id}] ending ${i}/${needEnd.length}`); endMe.end('end'); }); - })); + }, 4)); process.on('disconnect', mustCall(() => { debug(`[${id}] process disconnect, ending`); @@ -146,9 +149,22 @@ if (process.argv[2] === 'child') { server.on('close', mustCall(function() { closeEmitted = true; - child1.kill(); - child2.kill(); - child3.kill(); + // Clean up child processes. + try { + child1.kill(); + } catch { + debug('child process already terminated'); + } + try { + child2.kill(); + } catch { + debug('child process already terminated'); + } + try { + child3.kill(); + } catch { + debug('child process already terminated'); + } })); server.listen(0, '127.0.0.1');