From 855923ce1311d4d6a640e5d6565a1ffd9a382ef9 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Feb 2026 01:26:51 +0000 Subject: [PATCH] Bound bootstrap timeout configuration range Co-authored-by: Theo Browne --- apps/t3/src/runtimeApiServer.test.ts | 10 ++++++++++ apps/t3/src/runtimeApiServer.ts | 8 ++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/t3/src/runtimeApiServer.test.ts b/apps/t3/src/runtimeApiServer.test.ts index d9b08720f4..b928ed43af 100644 --- a/apps/t3/src/runtimeApiServer.test.ts +++ b/apps/t3/src/runtimeApiServer.test.ts @@ -250,6 +250,16 @@ describe("runtimeApiServer", () => { ).rejects.toThrow("Invalid bootstrapSessionTimeoutMs"); }); + it("rejects overly large bootstrap timeout configuration", async () => { + await expect( + startRuntimeApiServer({ + port: 0, + launchCwd: process.cwd(), + bootstrapSessionTimeoutMs: 120_001, + }), + ).rejects.toThrow("Invalid bootstrapSessionTimeoutMs"); + }); + it("rejects empty auth token configuration", async () => { await expect( startRuntimeApiServer({ diff --git a/apps/t3/src/runtimeApiServer.ts b/apps/t3/src/runtimeApiServer.ts index b0087f491f..6808d9b9f6 100644 --- a/apps/t3/src/runtimeApiServer.ts +++ b/apps/t3/src/runtimeApiServer.ts @@ -94,6 +94,7 @@ interface JsonRpcErrorResult { } const BOOTSTRAP_SESSION_TIMEOUT_MS = 3_000; +const MAX_BOOTSTRAP_SESSION_TIMEOUT_MS = 120_000; const MAX_WS_CLIENT_PAYLOAD_BYTES = 5 * 1024 * 1024; interface BootstrapSessionResult { @@ -372,9 +373,12 @@ export async function startRuntimeApiServer( options.bootstrapSessionTimeoutMs ?? BOOTSTRAP_SESSION_TIMEOUT_MS; if ( !Number.isInteger(bootstrapSessionTimeoutMs) || - bootstrapSessionTimeoutMs <= 0 + bootstrapSessionTimeoutMs <= 0 || + bootstrapSessionTimeoutMs > MAX_BOOTSTRAP_SESSION_TIMEOUT_MS ) { - throw new Error("Invalid bootstrapSessionTimeoutMs: expected positive integer."); + throw new Error( + `Invalid bootstrapSessionTimeoutMs: expected integer between 1 and ${MAX_BOOTSTRAP_SESSION_TIMEOUT_MS}.`, + ); } const providerManager = new ProviderManager(); const processManager = new ProcessManager();