From 3c735a0c80f09b7fa5064f6d610d3bd617795c67 Mon Sep 17 00:00:00 2001 From: sbrooke Date: Fri, 15 May 2026 17:03:05 -0400 Subject: [PATCH] feat(server): bump MAX_CONCURRENT_TASKS default from 3 to 5 (TAB-966) The previous default of 3 was sized against the memory math in TAB-964, which assumed in-pod Chromium browsers (~300-400MB each). In practice the pod connects to a remote browser pool over CDP and per-task memory in the pod is much smaller. 5 is comfortable on the 2Gi pod limit that the companion webservices-infra change lands. Companion infra change pins MAX_CONCURRENT_TASKS=5 in the configmap so deploys are explicit about the cap rather than relying on this default. Refs: TAB-966, TAB-964 --- packages/server/src/concurrencyGuard.test.ts | 18 ++++++++++++++++++ packages/server/src/concurrencyGuard.ts | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 packages/server/src/concurrencyGuard.test.ts diff --git a/packages/server/src/concurrencyGuard.test.ts b/packages/server/src/concurrencyGuard.test.ts new file mode 100644 index 00000000..6427df31 --- /dev/null +++ b/packages/server/src/concurrencyGuard.test.ts @@ -0,0 +1,18 @@ +import { describe, it, expect, afterEach } from "vitest"; +import { getMaxConcurrentTasks } from "./concurrencyGuard.js"; + +describe("concurrencyGuard default cap", () => { + afterEach(() => { + delete process.env.MAX_CONCURRENT_TASKS; + }); + + it("defaults to 5 when MAX_CONCURRENT_TASKS is unset", () => { + delete process.env.MAX_CONCURRENT_TASKS; + expect(getMaxConcurrentTasks()).toBe(5); + }); + + it("honors MAX_CONCURRENT_TASKS env override", () => { + process.env.MAX_CONCURRENT_TASKS = "12"; + expect(getMaxConcurrentTasks()).toBe(12); + }); +}); diff --git a/packages/server/src/concurrencyGuard.ts b/packages/server/src/concurrencyGuard.ts index b744aed1..50c8d79c 100644 --- a/packages/server/src/concurrencyGuard.ts +++ b/packages/server/src/concurrencyGuard.ts @@ -1,4 +1,4 @@ -const getMax = () => Number(process.env.MAX_CONCURRENT_TASKS ?? 3); +const getMax = () => Number(process.env.MAX_CONCURRENT_TASKS ?? 5); let activeTasks = 0;