server: add 5s timeout to all shell probes in env-runtime.js

This commit is contained in:
Mayuresh Kadu
2026-06-20 09:33:35 +01:00
parent 1439f5e838
commit 13caa698f3
@@ -4,6 +4,8 @@ import os from 'node:os';
import path from 'node:path'; import path from 'node:path';
import { mergePathValues } from './path-utils.js'; import { mergePathValues } from './path-utils.js';
const SHELL_PROBE_TIMEOUT_MS = 5_000;
export const createOpenCodeEnvRuntime = (deps) => { export const createOpenCodeEnvRuntime = (deps) => {
const { const {
state, state,
@@ -207,6 +209,7 @@ export const createOpenCodeEnvRuntime = (deps) => {
stdio: ['ignore', 'pipe', 'pipe'], stdio: ['ignore', 'pipe', 'pipe'],
maxBuffer: 10 * 1024 * 1024, maxBuffer: 10 * 1024 * 1024,
windowsHide: true, windowsHide: true,
timeout: SHELL_PROBE_TIMEOUT_MS,
}); });
if (result.status !== 0) { if (result.status !== 0) {
@@ -367,6 +370,7 @@ export const createOpenCodeEnvRuntime = (deps) => {
encoding: 'utf8', encoding: 'utf8',
stdio: ['ignore', 'pipe', 'pipe'], stdio: ['ignore', 'pipe', 'pipe'],
windowsHide: true, windowsHide: true,
timeout: SHELL_PROBE_TIMEOUT_MS,
}); });
if (result.status === 0) { if (result.status === 0) {
const found = (result.stdout || '').trim().split(/\s+/).pop() || ''; const found = (result.stdout || '').trim().split(/\s+/).pop() || '';
@@ -434,6 +438,7 @@ export const createOpenCodeEnvRuntime = (deps) => {
encoding: 'utf8', encoding: 'utf8',
stdio: ['ignore', 'pipe', 'pipe'], stdio: ['ignore', 'pipe', 'pipe'],
windowsHide: true, windowsHide: true,
timeout: SHELL_PROBE_TIMEOUT_MS,
}); });
if (result.status === 0) { if (result.status === 0) {
const found = (result.stdout || '').trim().split(/\s+/).pop() || ''; const found = (result.stdout || '').trim().split(/\s+/).pop() || '';
@@ -515,6 +520,7 @@ export const createOpenCodeEnvRuntime = (deps) => {
encoding: 'utf8', encoding: 'utf8',
stdio: ['ignore', 'pipe', 'pipe'], stdio: ['ignore', 'pipe', 'pipe'],
windowsHide: true, windowsHide: true,
timeout: SHELL_PROBE_TIMEOUT_MS,
}); });
if (result.status === 0) { if (result.status === 0) {
const found = (result.stdout || '').trim().split(/\s+/).pop() || ''; const found = (result.stdout || '').trim().split(/\s+/).pop() || '';