mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-06 17:57:52 +02:00
fix(hooks): bound plugin shell probe timeouts (#2547)
Co-authored-by: Haley Chen <2022hachen@gmail.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user