Files
paseo/packages/server/src/server/config-git.test.ts
T
Mohamed Boudra 2e188787ff Limit daemon-wide Git process pressure (#2797)
* perf(server): bound Git process starts

Git refresh bursts could keep creating short-lived processes at the concurrency ceiling, causing sustained process churn on constrained hosts. Apply one daemon-global start-rate and concurrency policy to every Git command while preserving the legacy concurrency environment variable.

* build(nix): update npm dependency hash

* fix(server): hold Git slots until process exit

* fix(server): enforce Git limits across process lifetime

* fix(server): align Git metrics with process exit

* Fix Git limiter test deadlocks

* Tune default Git process rate
2026-08-02 19:59:43 +02:00

90 lines
2.2 KiB
TypeScript

import { mkdtemp, rm, writeFile } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { afterEach, describe, expect, test } from "vitest";
import { loadConfig } from "./config.js";
const roots: string[] = [];
async function createHome(config: object = {}): Promise<string> {
const home = await mkdtemp(path.join(os.tmpdir(), "paseo-config-git-"));
roots.push(home);
await writeFile(path.join(home, "config.json"), JSON.stringify(config));
return home;
}
describe("daemon Git process config", () => {
afterEach(async () => {
await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })));
});
test("defaults the global process limits", async () => {
const home = await createHome();
expect(loadConfig(home, { env: {} }).git).toEqual({
maxProcessesPerSecond: 64,
maxProcessConcurrency: 8,
});
});
test("loads both limits from daemon.git", async () => {
const home = await createHome({
daemon: {
git: {
maxProcessesPerSecond: 5,
maxProcessConcurrency: 4,
},
},
});
expect(loadConfig(home, { env: {} }).git).toEqual({
maxProcessesPerSecond: 5,
maxProcessConcurrency: 4,
});
});
test("new environment variables override config.json", async () => {
const home = await createHome({
daemon: {
git: {
maxProcessesPerSecond: 5,
maxProcessConcurrency: 4,
},
},
});
expect(
loadConfig(home, {
env: {
PASEO_GIT_MAX_PROCESSES_PER_SECOND: "12",
PASEO_GIT_MAX_PROCESS_CONCURRENCY: "6",
},
}).git,
).toEqual({
maxProcessesPerSecond: 12,
maxProcessConcurrency: 6,
});
});
test("accepts legacy PASEO_GIT_CONCURRENCY below the renamed variable", async () => {
const home = await createHome();
expect(
loadConfig(home, {
env: {
PASEO_GIT_CONCURRENCY: "3",
},
}).git?.maxProcessConcurrency,
).toBe(3);
expect(
loadConfig(home, {
env: {
PASEO_GIT_CONCURRENCY: "3",
PASEO_GIT_MAX_PROCESS_CONCURRENCY: "7",
},
}).git?.maxProcessConcurrency,
).toBe(7);
});
});