@devries-cameron20 / t3code-1 / commits / 87cfd08b64
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): Antigravity no longer delays server startup by deleting old runtimes (#27651)

Co-authored-by: Lukas <340913497+LukeCommits@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Lukas committed Nov 1, 2026 at 23:47 UTC 87cfd08b64b6716dd9289fd04f712458e7988fa4
3 files changed +96 -8
apps/server/src/provider/Drivers/AntigravityDriver.ts
+4 -2
@@ -46,8 +46,8 @@ import {
46 import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
47 import type { ServerProviderDraft } from "@t3tools/provider-core/server/snapshotProbe";
48 import {
49 - removeAntigravityRuntimeTempDirs,
49 removeAntigravitySessionFiles,
50 + retireAntigravityRuntimeTempDirs,
51 } from "../acp/AntigravitySessionFiles.ts";
52 import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
53 import * as ProviderContinuationRequests from "@t3tools/provider-core/server/ProviderContinuationRequests";
@@ -150,9 +150,11 @@ export const AntigravityDriver: ProviderDriver<
150 directories.runtimeTemp,
151 path.join(profileDirectory, "antigravity-acp", "tmp"),
152 ]) {
153 - yield* removeAntigravityRuntimeTempDirs(directory).pipe(
153 + const removeRetired = yield* retireAntigravityRuntimeTempDirs(directory).pipe(
154 Effect.provideService(FileSystem.FileSystem, fileSystem),
155 + Effect.provideService(Path.Path, path),
156 );
157 + yield* Effect.forkScoped(removeRetired);
158 }
159 const continuationIdentity = defaultProviderContinuationIdentity({
160 driverKind: DRIVER,
apps/server/src/provider/acp/AntigravitySessionFiles.test.ts new
+64
@@ -0,0 +1,64 @@
1 +import * as NodeServices from "@effect/platform-node/NodeServices";
2 +import { expect, it } from "@effect/vitest";
3 +import * as Effect from "effect/Effect";
4 +import * as FileSystem from "effect/FileSystem";
5 +import * as Path from "effect/Path";
6 +import * as PlatformError from "effect/PlatformError";
7 +
8 +import { retireAntigravityRuntimeTempDirs } from "./AntigravitySessionFiles.ts";
9 +
10 +it.layer(NodeServices.layer)("retireAntigravityRuntimeTempDirs", (it) => {
11 + it.effect("moves leftovers aside at once and deletes them, plus older retirees, later", () =>
12 + Effect.gen(function* () {
13 + const fs = yield* FileSystem.FileSystem;
14 + const path = yield* Path.Path;
15 + const parent = yield* fs.makeTempDirectoryScoped();
16 + const runtimeTemp = path.join(parent, "abc123");
17 + const orphan = path.join(runtimeTemp, "run-orphan", "_MEI123");
18 + yield* fs.makeDirectory(orphan, { recursive: true });
19 + yield* fs.writeFileString(path.join(orphan, "payload.bin"), "stale");
20 + yield* fs.makeDirectory(path.join(parent, "abc123.old-unfinished", "runtime"), {
21 + recursive: true,
22 + });
23 + yield* fs.makeDirectory(path.join(parent, "other-instance"));
24 +
25 + const removeRetired = yield* retireAntigravityRuntimeTempDirs(runtimeTemp);
26 + expect(yield* fs.exists(runtimeTemp)).toBe(false);
27 + const retired = (yield* fs.readDirectory(parent)).filter((entry) =>
28 + entry.startsWith("abc123.old-"),
29 + );
30 + expect(retired).toHaveLength(2);
31 +
32 + yield* removeRetired;
33 + expect((yield* fs.readDirectory(parent)).toSorted()).toEqual(["other-instance"]);
34 + }).pipe(Effect.scoped),
35 + );
36 +
37 + it.effect(
38 + "deletes leftovers inline when they cannot be moved aside, such as on a full disk",
39 + () =>
40 + Effect.gen(function* () {
41 + const removed: Array<string> = [];
42 + const fs = FileSystem.makeNoop({
43 + exists: () => Effect.succeed(true),
44 + makeTempDirectory: () =>
45 + Effect.fail(
46 + PlatformError.systemError({
47 + _tag: "Unknown",
48 + module: "FileSystem",
49 + method: "makeTempDirectory",
50 + description: "ENOSPC",
51 + }),
52 + ),
53 + remove: (path) => Effect.sync(() => void removed.push(path)),
54 + readDirectory: () => Effect.succeed([]),
55 + });
56 +
57 + const removeRetired = yield* retireAntigravityRuntimeTempDirs(
58 + "/state/antigravity-tmp/abc123",
59 + ).pipe(Effect.provideService(FileSystem.FileSystem, fs));
60 + yield* removeRetired;
61 + expect(removed).toEqual(["/state/antigravity-tmp/abc123"]);
62 + }),
63 + );
64 +});
apps/server/src/provider/acp/AntigravitySessionFiles.ts
+28 -6
@@ -42,13 +42,35 @@ export const removeAntigravitySessionFiles = Effect.fn("removeAntigravitySession
42 Effect.catch(() => Effect.logWarning("Could not remove temporary Antigravity session files.")),
43 );
44
45 -/** Sweep only private runtimes before launch; Windows does not protect live extracted data files from deletion. */
46 -export const removeAntigravityRuntimeTempDirs = Effect.fn("removeAntigravityRuntimeTempDirs")(
45 +const warnRuntimeTempLeftovers = Effect.logWarning(
46 + "Could not remove leftover Antigravity runtime temp files.",
47 +);
48 +
49 +/**
50 + * Sweep only private runtimes before launch; Windows does not protect live extracted data files from deletion.
51 + * Moves leftovers aside and returns their slow deletion (seconds on Windows) to run off the startup path.
52 + */
53 +export const retireAntigravityRuntimeTempDirs = Effect.fn("retireAntigravityRuntimeTempDirs")(
54 function* (tempDirectory: string) {
55 const fs = yield* FileSystem.FileSystem;
49 - yield* fs.remove(tempDirectory, { recursive: true, force: true });
56 + const path = yield* Path.Path;
57 + const parent = path.dirname(tempDirectory);
58 + const prefix = `${path.basename(tempDirectory)}.old-`;
59 + if (yield* fs.exists(tempDirectory)) {
60 + yield* fs.makeTempDirectory({ directory: parent, prefix }).pipe(
61 + Effect.flatMap((retired) => fs.rename(tempDirectory, path.join(retired, "runtime"))),
62 + Effect.catch(() => fs.remove(tempDirectory, { recursive: true, force: true })),
63 + );
64 + }
65 + const entries = yield* fs.readDirectory(parent).pipe(Effect.orElseSucceed(() => []));
66 + return Effect.forEach(
67 + entries.filter((entry) => entry.startsWith(prefix)),
68 + (entry) =>
69 + fs
70 + .remove(path.join(parent, entry), { recursive: true, force: true })
71 + .pipe(Effect.catch(() => warnRuntimeTempLeftovers)),
72 + { discard: true },
73 + );
74 },
51 - Effect.catch(() =>
52 - Effect.logWarning("Could not remove leftover Antigravity runtime temp files."),
53 - ),
75 + Effect.catch(() => warnRuntimeTempLeftovers.pipe(Effect.as(Effect.void))),
76 );