fix(exec): wait for the child process to close

This commit is contained in:
Zoltan Kochan
2025-07-18 23:24:49 +02:00
parent ea2d2ea6b2
commit b7d9301e4b
2 changed files with 13 additions and 5 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-script-runners": patch
---
Fix waiting for closed child process.

View File

@@ -281,11 +281,14 @@ export async function handler (
}
child.stdout!.on('data', logFn('stdout'))
child.stderr!.on('data', logFn('stderr'))
void child.once('close', exitCode => {
lifecycleLogger.debug({
...lifecycleOpts,
exitCode: exitCode ?? 1,
optional: false,
await new Promise<void>((resolve) => {
void child.once('close', exitCode => {
lifecycleLogger.debug({
...lifecycleOpts,
exitCode: exitCode ?? 1,
optional: false,
})
resolve()
})
})
await child