Skip to content

Commit 192ff9f

Browse files
committed
fix(server): share Git process limit across driver instances
1 parent c1dd964 commit 192ff9f

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const initRepoWithCommit = (
139139
return { initialBranch };
140140
});
141141

142-
it.effect("bounds Git bursts without counting queue time against command timeouts", () =>
142+
it.effect("bounds Git bursts across drivers without timing out queued commands", () =>
143143
Effect.gen(function* () {
144144
const gate = yield* Deferred.make<void>();
145145
const starts = yield* Queue.unbounded<number>();
@@ -158,18 +158,22 @@ it.effect("bounds Git bursts without counting queue time against command timeout
158158
() => Effect.sync(() => active--),
159159
),
160160
);
161-
const driver = yield* makeGitVcsDriverCore().pipe(
162-
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
161+
const drivers = yield* Effect.all(
162+
Array.from({ length: 16 }, () =>
163+
makeGitVcsDriverCore().pipe(
164+
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
165+
),
166+
),
163167
);
164-
const burst = yield* Effect.all(
165-
Array.from({ length: 16 }, (_, index) =>
168+
const burst = yield* Effect.forEach(
169+
drivers,
170+
(driver, index) =>
166171
driver.execute({
167172
operation: "test.gitBurst",
168173
cwd: "/repo",
169174
args: ["rev-parse", "HEAD"],
170175
timeoutMs: index < 4 ? null : 1_000,
171176
}),
172-
),
173177
{ concurrency: "unbounded" },
174178
).pipe(Effect.forkChild);
175179

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
import { ServerConfig } from "../config.ts";
4040

4141
const DEFAULT_TIMEOUT_MS = 30_000;
42+
const gitProcesses = Semaphore.makeUnsafe(4);
4243
// `git worktree add` checks out the full tree, so on large repositories it can
4344
// take well beyond the default 30s (e.g. a 375k-file repo takes ~40s on an idle
4445
// machine). Give it generous headroom while still bounding a genuinely hung git.
@@ -759,7 +760,6 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
759760
const fileSystem = yield* FileSystem.FileSystem;
760761
const path = yield* Path.Path;
761762
const commandSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
762-
const gitProcesses = yield* Semaphore.make(4);
763763
const { worktreesDir } = yield* ServerConfig;
764764
const crypto = yield* Crypto.Crypto;
765765

0 commit comments

Comments
 (0)