@devries-cameron20 / t3code Mirror · read-only / commits / 1b555ccb01
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 07:15 UTC

fix(server): Antigravity install on Windows survives a briefly locked runtime folder (#29279)

Julius Marminge committed Nov 18, 2026 at 21:02 UTC 1b555ccb0145747ef9c42b51e963378ee080bdb0
2 files changed +66 -12
apps/server/src/provider/AntigravityInstallation.test.ts
+49
@@ -1376,6 +1376,55 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst
1376 }),
1377 );
1378
1379 + it.effect("publishes a Windows release once a transient EPERM on the release rename clears", () =>
1380 + Effect.gen(function* () {
1381 + const fs = yield* FileSystem.FileSystem;
1382 + const path = yield* Path.Path;
1383 + const archive = Buffer.from(zipFixtures.windows, "base64");
1384 + const releaseRenameDenied = yield* Deferred.make<void>();
1385 + let releaseRenameDenials = 3;
1386 + const { installation } = yield* makeHarness({
1387 + platform: "win32",
1388 + archive,
1389 + fileSystem: FileSystem.FileSystem.of({
1390 + ...fs,
1391 + rename: (source, target) =>
1392 + Effect.suspend(() => {
1393 + if (
1394 + path.basename(path.dirname(target)) !== "versions" ||
1395 + releaseRenameDenials === 0
1396 + ) {
1397 + return fs.rename(source, target);
1398 + }
1399 + releaseRenameDenials -= 1;
1400 + return Deferred.succeed(releaseRenameDenied, undefined).pipe(
1401 + Effect.andThen(
1402 + Effect.fail(
1403 + PlatformError.systemError({
1404 + _tag: "Unknown",
1405 + module: "FileSystem",
1406 + method: "rename",
1407 + pathOrDescriptor: source,
1408 + description: "EPERM: operation not permitted, rename",
1409 + }),
1410 + ),
1411 + ),
1412 + );
1413 + }),
1414 + }),
1415 + });
1416 + yield* installation.start;
1417 + const terminal = yield* terminalState(installation).pipe(Effect.forkChild);
1418 + yield* Deferred.await(releaseRenameDenied);
1419 + yield* TestClock.adjust("30 seconds");
1420 + expect(yield* Fiber.join(terminal)).toMatchObject({
1421 + phase: "succeeded",
1422 + installedVersion: "fixture-new",
1423 + });
1424 + expect((yield* installation.resolve()).version).toBe("fixture-new");
1425 + }),
1426 + );
1427 +
1428 it.effect("reports unsupported hosts without downloading or changing state", () =>
1429 Effect.gen(function* () {
1430 const { installation, requests } = yield* makeHarness({ asset: null, platform: "darwin" });
apps/server/src/provider/AntigravityInstallation.ts
+17 -12
@@ -20,6 +20,7 @@ import * as FileSystem from "effect/FileSystem";
20 import * as Layer from "effect/Layer";
21 import * as Option from "effect/Option";
22 import * as Path from "effect/Path";
23 +import type { PlatformError } from "effect/PlatformError";
24 import * as Schema from "effect/Schema";
25 import * as Schedule from "effect/Schedule";
26 import * as Scope from "effect/Scope";
@@ -206,6 +207,18 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
207 );
208 const versionsDirectory = path.join(managedDirectory, "versions");
209 const activePath = path.join(managedDirectory, "active.json");
210 + // Windows briefly keeps handles on fresh runtime files after taskkill or an antivirus scan; retry for up to 10 seconds.
211 + const retryWhileWindowsHoldsHandles = <A, R>(effect: Effect.Effect<A, PlatformError, R>) =>
212 + effect.pipe(
213 + Effect.retry({
214 + times: platform === "win32" ? 40 : 0,
215 + schedule: Schedule.spaced("250 millis"),
216 + while: (error) =>
217 + error.reason._tag === "PermissionDenied" ||
218 + error.reason._tag === "Busy" ||
219 + error.reason._tag === "Unknown",
220 + }),
221 + );
222 const gate = yield* Semaphore.make(1);
223 const leases = new Map<string, number>();
224 let running: { readonly operationId: string; readonly fiber: Fiber.Fiber<void> } | undefined;
@@ -461,18 +474,9 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
474 const profileDirectory = yield* Effect.acquireRelease(
475 fs.makeTempDirectory({ prefix: "t3-antigravity-validate-" }),
476 (directory) =>
464 - fs.remove(directory, { recursive: true, force: true }).pipe(
465 - // Windows may retain DLL handles briefly after taskkill returns.
466 - Effect.retry({
467 - times: platform === "win32" ? 10 : 0,
468 - schedule: Schedule.spaced("100 millis"),
469 - while: (error) =>
470 - error.reason._tag === "PermissionDenied" ||
471 - error.reason._tag === "Busy" ||
472 - error.reason._tag === "Unknown",
473 - }),
474 - Effect.orDie,
475 - ),
477 + fs
478 + .remove(directory, { recursive: true, force: true })
479 + .pipe(retryWhileWindowsHoldsHandles, Effect.orDie),
480 );
481 const profile = yield* prepareAntigravityProfile({
482 profileDirectory,
@@ -908,6 +912,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
912 { flag: "wx", mode: 0o600 },
913 );
914 yield* fs.rename(pairDirectory, destination).pipe(
915 + retryWhileWindowsHoldsHandles,
916 Effect.catch((cause) =>
917 completedRelease(releaseId).pipe(
918 Effect.flatMap((existing) =>