Skip to content

Commit 30035f9

Browse files
Remove unused event listener after promise settlement in spawnDetachedProcess
Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
1 parent e5cea81 commit 30035f9

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

apps/server/src/processRunner.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,18 @@ export function spawnDetachedProcess(
364364
});
365365

366366
const handleSpawn = () => {
367+
child.removeListener("error", handleError);
367368
child.unref();
368369
resolve();
369370
};
370371

371-
child.once("spawn", handleSpawn);
372-
child.once("error", (error) => {
372+
const handleError = (error: Error) => {
373+
child.removeListener("spawn", handleSpawn);
373374
reject(normalizeSpawnError(command, args, error));
374-
});
375+
};
376+
377+
child.once("spawn", handleSpawn);
378+
child.once("error", handleError);
375379
});
376380
}
377381

0 commit comments

Comments
 (0)