mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-11 03:38:07 +00:00
fix(server): make the analyze worker's IPC send() failure-safe (#2264 review P3)
The worker's send() used `process.send?.(msg)` — the `?.` guards an undefined channel but not a throw from an already-closed one (ERR_IPC_CHANNEL_CLOSED). A throw in the catch-branch send() would escape the message handler and skip the scheduled `setTimeout(process.exit(0))`, stranding the worker (with skip-close leaving native handles open, #2264). Wrap process.send in try/catch so the exit always fires; a vanished child is a failure to the parent regardless. Not unit-tested: send() is module-private and importing the worker registers process signal handlers; the change is a defensive try/catch around one call. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JBJomjoTdBV2eveDVq4JMm
This commit is contained in:
parent
17b0b93e35
commit
caa8543b2b
1 changed files with 8 additions and 1 deletions
|
|
@ -44,7 +44,14 @@ export interface ErrorMessage {
|
|||
export type WorkerMessage = ProgressMessage | CompleteMessage | ErrorMessage;
|
||||
|
||||
function send(msg: WorkerMessage) {
|
||||
process.send?.(msg);
|
||||
try {
|
||||
process.send?.(msg);
|
||||
} catch {
|
||||
// The parent may have already disconnected the IPC channel
|
||||
// (ERR_IPC_CHANNEL_CLOSED). Swallow so a failed notification can't escape the
|
||||
// message/SIGTERM handlers and skip their scheduled process.exit (#2264 review
|
||||
// P3) — a vanished child is treated as a failure by the parent regardless.
|
||||
}
|
||||
}
|
||||
|
||||
// Catch uncaught exceptions and unhandled rejections — report to parent
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue