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
Fix `.pipe()` with the `stdio` option and orphaned destination subprocessesSindre Sorhusbefore adoption8d3f0a9
lines 1–16why, one step back1#!/usr/bin/env node2import process from 'node:process';3import {setTimeout} from 'node:timers/promises';4import {execa} from '../../index.js';56// The destination subprocess is spawned before the `to` option is validated.7// Its error must not become an unhandled rejection, which would crash this process.8// It must also be terminated, otherwise it would prevent this process from exiting.9const [destinationFile] = process.argv.slice(2);1011try {12 await execa('empty.js', {stdout: 'ignore'}).pipe(destinationFile, [], {to: 'fd9'});13} catch {}1415await setTimeout(500);16process.stdout.write('REACHED THE END');