pipe-destination-error.js
This file
Path
test/fixtures/pipe-destination-error.js
16 lines · 609 bytes · JavaScript
Last changed by
Fix `.pipe()` with the `stdio` option and orphaned destination subprocessesSindre Sorhusbefore adoption8d3f0a9
History of this fileTake it
1234567891011121314151617#!/usr/bin/env nodeimport process from 'node:process';import {setTimeout} from 'node:timers/promises';import {execa} from '../../index.js';
// The destination subprocess is spawned before the `to` option is validated.// Its error must not become an unhandled rejection, which would crash this process.// It must also be terminated, otherwise it would prevent this process from exiting.const [destinationFile] = process.argv.slice(2);
try { await execa('empty.js', {stdout: 'ignore'}).pipe(destinationFile, [], {to: 'fd9'});} catch {}
await setTimeout(500);process.stdout.write('REACHED THE END');