SIGN IN SIGN UP

fix(vscode): prevent hook spawn failures from crashing the core process (#13422)

* fix(vscode): prevent hook spawn failures from crashing the core process

A hook child-process spawn failure emitted "error" on HookProcess with no
listener registered, which Node's EventEmitter turns into an uncaught
exception - killing the entire cline-core process instead of failing the
one hook open. Guard the emit behind listenerCount so the rejection (which
StdioHookRunner handles) is the only propagation path.

The trigger was a workspace root that no longer exists on disk passed as
the spawn cwd: Node reports a nonexistent cwd as a misleading ENOENT on
the launcher binary ("spawn /bin/sh ENOENT"). Validate cwd existence in
HookProcess right before spawning - falling back to no explicit cwd with
a warning that names the missing directory - and when a spawn still fails
ENOENT because the directory vanished in between, name it in the error
message instead of blaming the shell.

* fix(vscode): fail hooks with a missing working directory instead of relocating them

Running a hook whose assigned cwd no longer exists from the host
process's own working directory would let its relative paths read and
write an unrelated location (e.g. the IDE install directory). Reject
before spawning, with an error naming the missing directory; the runner
reports the hook as failed and the task continues. Also carry pre-spawn
failure messages into HookExecutionError details so the cause is not
reduced to a bare "exited with code 1".
M
Mikołaj Kondratek committed
cea134be06cbb60af4a7341ddc065c3b8be6be86
Parent: 1986fa5
Committed by GitHub <noreply@github.com> on 8/29/2026, 7:07:30 AM