fix(hooks): bound plugin shell probe timeouts

This commit is contained in:
Haley Chen
2026-07-22 13:00:22 -04:00
parent 8348fb5387
commit 3c1764b548
+8 -2
View File
@@ -6,6 +6,8 @@ const path = require('path');
const { spawnSync } = require('child_process');
const { ensureAgentDataHomeEnv } = require('../lib/agent-data-home');
const SHELL_PROBE_TIMEOUT_MS = 2000;
function readStdinRaw() {
try {
return fs.readFileSync(0, 'utf8');
@@ -95,7 +97,7 @@ function findShellBinary() {
const probe = spawnSync(candidate, isPowerShellBin(candidate) ? psProbeArgs : shProbeArgs, {
stdio: 'ignore',
windowsHide: true,
timeout: 30000,
timeout: SHELL_PROBE_TIMEOUT_MS,
});
// A candidate is only usable if it both spawns AND exits cleanly. The
// Windows System32 bash.exe WSL launcher spawns without error but exits
@@ -120,7 +122,11 @@ function findBashBinary() {
candidates.push('bash.exe', 'bash');
for (const candidate of candidates) {
const probe = spawnSync(candidate, ['-c', ':'], { stdio: 'ignore', windowsHide: true, timeout: 30000 });
const probe = spawnSync(candidate, ['-c', ':'], {
stdio: 'ignore',
windowsHide: true,
timeout: SHELL_PROBE_TIMEOUT_MS,
});
// Require a clean exit, not just a successful spawn: the Windows System32
// bash.exe WSL stub spawns fine but exits non-zero with no distro installed.
if (!probe.error && probe.status === 0) {