Skip to content

Commit 0f4c368

Browse files
committed
Fix child process leak: close ACP runtime after text generation
Wrap makeCursorAcpRuntime with Effect.acquireRelease so that runtime.close is called as a finalizer when the Effect.scoped region exits. Previously, the internal runtimeScope (which owns the spawned child process) was never closed, leaking a process on every call to generateCommitMessage, generatePrContent, generateBranchName, or generateThreadTitle.
1 parent 218cd8b commit 0f4c368

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

apps/server/src/git/Layers/CursorTextGeneration.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,15 @@ const makeCursorTextGeneration = Effect.gen(function* () {
126126
).pipe(Effect.catch(() => Effect.undefined));
127127

128128
const outputRef = yield* Ref.make("");
129-
const runtime = yield* makeCursorAcpRuntime({
130-
cursorSettings,
131-
childProcessSpawner: commandSpawner,
132-
cwd,
133-
clientInfo: { name: "t3-code-git-text", version: "0.0.0" },
134-
});
129+
const runtime = yield* Effect.acquireRelease(
130+
makeCursorAcpRuntime({
131+
cursorSettings,
132+
childProcessSpawner: commandSpawner,
133+
cwd,
134+
clientInfo: { name: "t3-code-git-text", version: "0.0.0" },
135+
}),
136+
(rt) => rt.close,
137+
);
135138

136139
yield* runtime.handleSessionUpdate((notification) => {
137140
const update = notification.update;

0 commit comments

Comments
 (0)