fix(plugin): bound kubernetes sandbox execution

This commit is contained in:
Dotta
2026-05-12 12:34:08 -05:00
committed by Chris Farhood
parent e691d30d12
commit 39d81c732c
5 changed files with 72 additions and 25 deletions
@@ -21,6 +21,7 @@ export async function execInPod(
containerName: string,
command: string[],
stdin?: string,
timeoutMs?: number,
): Promise<{ exitCode: number; stdout: string; stderr: string }> {
const exec = new Exec(kc);
const stdoutStream = new PassThrough();
@@ -45,9 +46,16 @@ export async function execInPod(
return await new Promise<{ exitCode: number; stdout: string; stderr: string }>(
(resolve, reject) => {
let settled = false;
const timeout =
typeof timeoutMs === "number" && timeoutMs > 0
? setTimeout(() => {
finishWithTransportFailure(`Kubernetes exec timed out after ${timeoutMs}ms`);
}, timeoutMs)
: null;
const finish = (result: { exitCode: number; stdout: string; stderr: string }) => {
if (settled) return;
settled = true;
if (timeout) clearTimeout(timeout);
resolve(result);
};
const finishWithTransportFailure = (message: string) => {