Skip to content

Commit

Permalink
fix: ignore plugin process kill errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Dec 10, 2024
1 parent ef92c48 commit f0ff5e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 7 additions & 1 deletion packages/build/src/plugins/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,11 @@ const stopPlugin = async function ({
})
childProcess.disconnect()
}
childProcess.kill()
try {
childProcess.kill()
} catch {
// In Node 22, there's a bug where attempting to kill a child process
// results in an EPERM error. Ignore the error in that case.
// See: https://github.com/nodejs/node/issues/51766
}
}
12 changes: 9 additions & 3 deletions packages/edge-bundler/node/server/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@ const killProcess = (ps: ExecaChildProcess<string>) => {
ps.on('close', resolve)
ps.on('error', reject)

ps.kill('SIGTERM', {
forceKillAfterTimeout: SERVER_KILL_TIMEOUT,
})
try {
ps.kill('SIGTERM', {
forceKillAfterTimeout: SERVER_KILL_TIMEOUT,
})
} catch {
// In Node 22, there's a bug where attempting to kill a child process
// results in an EPERM error. Ignore the error in that case.
// See: https://github.com/nodejs/node/issues/51766
}
})
}

Expand Down

0 comments on commit f0ff5e6

Please sign in to comment.