Skip to content

Commit

Permalink
test-pipe-unref.js
Browse files Browse the repository at this point in the history
  • Loading branch information
pfgithub committed Jan 30, 2025
1 parent 4f2391e commit 4888f2b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/js/node/test/parallel/test-pipe-unref.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';
const common = require('../common');
const net = require('net');
const assert = require('assert');
const { fork } = require('child_process');

// This test should end immediately after `unref` is called
// The pipe will stay open as Node.js completes, thus run in a child process
// so that tmpdir can be cleaned up.

const tmpdir = require('../common/tmpdir');

if (process.argv[2] !== 'child') {
// Parent
tmpdir.refresh();

// Run test
const child = fork(__filename, ['child'], { stdio: 'inherit' });
child.on('exit', common.mustCall(function(code) {
assert.strictEqual(code, 0);
}));

return;
}

// Child
const s = net.Server();
s.listen(common.PIPE);
s.unref();

0 comments on commit 4888f2b

Please sign in to comment.