fix: close read line interfaces on spawn errors (#693)
This commit is contained in:
parent
3c9620f973
commit
fa8e57a589
1 changed files with 5 additions and 1 deletions
|
|
@ -83,11 +83,12 @@ export function safeSpawn(params: SafeSpawnParams): Promise<SpawnResult> {
|
||||||
child.stderr.setEncoding("utf8");
|
child.stderr.setEncoding("utf8");
|
||||||
|
|
||||||
const rlErr = createInterface({ input: child.stderr });
|
const rlErr = createInterface({ input: child.stderr });
|
||||||
|
let rl: ReturnType<typeof createInterface> | undefined;
|
||||||
|
|
||||||
if (stdoutMode === "lines") {
|
if (stdoutMode === "lines") {
|
||||||
child.stdout.setEncoding("utf8");
|
child.stdout.setEncoding("utf8");
|
||||||
|
|
||||||
const rl = createInterface({ input: child.stdout });
|
rl = createInterface({ input: child.stdout });
|
||||||
|
|
||||||
rl.on("line", (line) => {
|
rl.on("line", (line) => {
|
||||||
if (onStdout) onStdout(line);
|
if (onStdout) onStdout(line);
|
||||||
|
|
@ -107,6 +108,9 @@ export function safeSpawn(params: SafeSpawnParams): Promise<SpawnResult> {
|
||||||
});
|
});
|
||||||
|
|
||||||
child.on("error", (err) => {
|
child.on("error", (err) => {
|
||||||
|
rlErr.close();
|
||||||
|
rl?.close();
|
||||||
|
|
||||||
resolve({
|
resolve({
|
||||||
exitCode: -1,
|
exitCode: -1,
|
||||||
summary: lastStdout,
|
summary: lastStdout,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue