Bound bootstrap timeout configuration range

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-10 01:26:51 +00:00
1 parent f951587e52
commit 855923ce13
2 files changed
+16 -2

No files matched your search

+10
View File
@@ -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({
+6 -2
View File
@@ -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();