fix(hooks): bound plugin shell probe timeouts (#2547)

Co-authored-by: Haley Chen <2022hachen@gmail.com>
This commit is contained in:
haelyra
2026-07-22 13:15:52 -04:00
committed by GitHub
co-authored by Haley Chen
parent 8348fb5387
commit b6652335d3
+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) {