The best way to control Claude Code, Codex and more from any computer or phone
fix(server): report managed runtime verification timeouts (#37896)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
primevishnu committed
Nov 17, 2026 at 11:06 UTC
2b2d65d131332d9fb15f5390d2d79ab6e21e3825
4 files changed
+155
-28
apps/server/src/provider/AntigravityInstallation.test.ts
+58
@@ -17,6 +17,7 @@ import * as Schema from "effect/Schema";
17
import * as Scope from "effect/Scope";
18
import * as Sink from "effect/Sink";
19
import * as Stream from "effect/Stream";
20
+import * as TestClock from "effect/testing/TestClock";
21
import { HttpClient, HttpClientError, HttpClientResponse } from "effect/http";
22
import * as ChildProcess from "effect/process/ChildProcess";
23
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
@@ -717,6 +718,63 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("Antigravity inst
718
}),
719
);
720
721
+ it.effect.each(["downloaded", "existing", "concurrent"] as const)(
722
+ "reports a verification timeout for a %s runtime without changing the active release",
723
+ (source) =>
724
+ Effect.gen(function* () {
725
+ const fs = yield* FileSystem.FileSystem;
726
+ const path = yield* Path.Path;
727
+ const asset = yield* releaseAsset();
728
+ const entered = yield* Deferred.make<void>();
729
+ let verificationCount = 0;
730
+ const { installation, stagingReleased, requests, validations } = yield* makeHarness({
731
+ previous: true,
732
+ asset,
733
+ fileSystem: FileSystem.FileSystem.of({
734
+ ...fs,
735
+ rename: (from, to) =>
736
+ source === "concurrent" && path.basename(path.dirname(to)) === "versions"
737
+ ? writeRelease(path.dirname(path.dirname(to)), asset, false).pipe(
738
+ Effect.provideService(FileSystem.FileSystem, fs),
739
+ Effect.provideService(Path.Path, path),
740
+ Effect.andThen(
741
+ Effect.fail(
742
+ PlatformError.systemError({
743
+ _tag: "AlreadyExists",
744
+ module: "FileSystem",
745
+ method: "rename",
746
+ pathOrDescriptor: to,
747
+ }),
748
+ ),
749
+ ),
750
+ )
751
+ : fs.rename(from, to),
752
+ }),
753
+ validate: () =>
754
+ Effect.suspend(() =>
755
+ source === "concurrent" && verificationCount++ === 0
756
+ ? Effect.void
757
+ : Deferred.succeed(entered, undefined).pipe(Effect.andThen(Effect.never)),
758
+ ),
759
+ });
760
+ if (source === "existing") {
761
+ yield* writeRelease(installation.managedDirectory, asset, false);
762
+ }
763
+ yield* installation.start;
764
+ yield* Deferred.await(entered);
765
+ yield* TestClock.adjust("90 seconds");
766
+ expect(yield* terminalState(installation)).toMatchObject({
767
+ phase: "failed",
768
+ message:
769
+ "Antigravity runtime verification timed out after 90 seconds. Check this environment's server logs for startup errors, then retry installation.",
770
+ });
771
+ if (source !== "existing") yield* Deferred.await(stagingReleased);
772
+ yield* expectPreviousRelease(installation);
773
+ expect(requests).toHaveLength(source === "existing" ? 0 : 1);
774
+ expect(validations).toHaveLength(source === "concurrent" ? 2 : 1);
775
+ }),
776
+ );
777
+
778
it.effect.each(["download", "extract", "active pointer"] as const)(
779
"preserves the old runtime after an ENOSPC error during %s",
780
(stage) =>
apps/server/src/provider/AntigravityInstallation.ts
+22
-16
@@ -444,6 +444,16 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
444
),
445
);
446
447
+ const withValidationTimeout = Effect.timeoutOrElse({
448
+ duration: VALIDATION_TIMEOUT,
449
+ orElse: () =>
450
+ Effect.fail(
451
+ installationError(
452
+ "verify",
453
+ "Antigravity runtime verification timed out after 90 seconds. Check this environment's server logs for startup errors, then retry installation.",
454
+ ),
455
+ ),
456
+ });
457
const validate =
458
options.validate ??
459
Effect.fn("AntigravityInstallation.validate")(
@@ -606,10 +616,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
616
);
617
}
618
yield* report("verifying", "Checking the installed runtime.");
609
- yield* validate(existing, asset.version).pipe(
610
- Effect.scoped,
611
- Effect.timeout(VALIDATION_TIMEOUT),
612
- );
619
+ yield* validate(existing, asset.version).pipe(Effect.scoped, withValidationTimeout);
620
yield* activate();
621
return;
622
}
@@ -866,7 +873,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
873
managedVersionDirectory: pairDirectory,
874
},
875
asset.version,
869
- ).pipe(Effect.scoped, Effect.timeout(VALIDATION_TIMEOUT));
876
+ ).pipe(Effect.scoped, withValidationTimeout);
877
const record: InstalledRelease = {
878
releaseId,
879
version: asset.version,
@@ -889,10 +896,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
896
completedRelease(releaseId).pipe(
897
Effect.flatMap((existing) =>
898
existing.version === asset.version
892
- ? validate(existing, asset.version).pipe(
893
- Effect.scoped,
894
- Effect.timeout(VALIDATION_TIMEOUT),
895
- )
899
+ ? validate(existing, asset.version).pipe(Effect.scoped, withValidationTimeout)
900
: Effect.fail(
901
installationError(
902
"activate",
@@ -900,12 +904,14 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
904
),
905
),
906
),
903
- Effect.mapError(() =>
904
- installationError(
905
- "activate",
906
- "Could not publish the Antigravity runtime. The previous release is unchanged. Try again.",
907
- cause,
908
- ),
907
+ Effect.mapError((error) =>
908
+ isInstallationError(error) && error.operation === "verify"
909
+ ? error
910
+ : installationError(
911
+ "activate",
912
+ "Could not publish the Antigravity runtime. The previous release is unchanged. Try again.",
913
+ cause,
914
+ ),
915
),
916
),
917
),
@@ -1019,7 +1025,7 @@ export const makeAntigravityInstallation = Effect.fn("AntigravityInstallation.ma
1025
? install(asset!)
1026
: validate(reuse, reuse.version!).pipe(
1027
Effect.scoped,
1022
- Effect.timeout(VALIDATION_TIMEOUT),
1028
+ withValidationTimeout,
1029
Effect.andThen(ensureEligible(reuse.version!)),
1030
Effect.andThen(
1031
SubscriptionRef.update(state, (value) => ({
apps/server/src/provider/CodexInstallation.test.ts
+62
@@ -461,6 +461,68 @@ it.effect(
461
}).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
462
);
463
464
+it.effect.each(["cached update", "reverify"] as const)(
465
+ "reports a verification timeout during %s and preserves the managed runtime",
466
+ (operation) =>
467
+ Effect.gen(function* () {
468
+ const fs = yield* FileSystem.FileSystem;
469
+ const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-codex-verify-test-" });
470
+ const managed = `${baseDir}/tools/codex`;
471
+ const installedVersion = operation === "cached update" ? "0.156.0" : asset.version;
472
+ const target = "aarch64-pc-windows-msvc";
473
+ const checksum = "a".repeat(64);
474
+ for (const version of new Set([installedVersion, asset.version])) {
475
+ const directory = `${managed}/${version}`;
476
+ yield* fs.makeDirectory(`${directory}/bin`, { recursive: true });
477
+ yield* fs.makeDirectory(`${directory}/codex-path`, { recursive: true });
478
+ for (const name of ["bin/codex.exe", "bin/codex-code-mode-host.exe", "codex-path/rg.exe"]) {
479
+ yield* fs.writeFileString(`${directory}/${name}`, "fixture executable");
480
+ }
481
+ yield* fs.writeFileString(
482
+ `${directory}/codex-package.json`,
483
+ JSON.stringify({ layoutVersion: 1, version, target, entrypoint: "bin/codex.exe" }),
484
+ );
485
+ yield* fs.writeFileString(
486
+ `${directory}/.install-complete.json`,
487
+ JSON.stringify({ version, target, sha256: checksum }),
488
+ );
489
+ }
490
+ const pointer = JSON.stringify({ version: installedVersion });
491
+ yield* fs.writeFileString(`${managed}/active.json`, pointer);
492
+ const entered = yield* Deferred.make<void>();
493
+ const h = yield* makeHarness({
494
+ baseDir,
495
+ platform: "win32",
496
+ manifestCurrent: Effect.succeed({
497
+ ...ModelManifest.BUNDLED_MODEL_MANIFEST,
498
+ compatibility: [
499
+ {
500
+ driver: "codex",
501
+ t3CodeRange: ">=0.0.0",
502
+ ranges: [{ range: ">=0.156.0", status: "supported" }],
503
+ },
504
+ ],
505
+ }),
506
+ options: {
507
+ releaseAsset: operation === "reverify" ? null : { ...asset, target, sha256: checksum },
508
+ validate: () => Deferred.succeed(entered, undefined).pipe(Effect.andThen(Effect.never)),
509
+ },
510
+ });
511
+ yield* h.installation.start;
512
+ yield* Deferred.await(entered);
513
+ yield* TestClock.adjust("90 seconds");
514
+ expect(yield* terminalState(h.installation)).toMatchObject({
515
+ phase: "failed",
516
+ installedVersion,
517
+ message:
518
+ "Codex runtime verification timed out after 90 seconds. Check this environment's server logs for startup errors, then retry installation.",
519
+ });
520
+ expect(yield* fs.readFileString(`${managed}/active.json`)).toBe(pointer);
521
+ expect((yield* h.installation.resolve()).version).toBe(installedVersion);
522
+ expect(h.downloads()).toBe(0);
523
+ }).pipe(Effect.scoped, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
524
+);
525
+
526
it.effect("reports a download timeout and cleans the staging directory", () =>
527
Effect.gen(function* () {
528
const started = yield* Deferred.make<void>();
apps/server/src/provider/CodexInstallation.ts
+13
-12
@@ -543,6 +543,16 @@ export const makeCodexInstallation = Effect.fn("makeCodexInstallation")(function
543
);
544
return true;
545
});
546
+ const withValidationTimeout = Effect.timeoutOrElse({
547
+ duration: "90 seconds",
548
+ orElse: () =>
549
+ Effect.fail(
550
+ installationError(
551
+ "verify",
552
+ "Codex runtime verification timed out after 90 seconds. Check this environment's server logs for startup errors, then retry installation.",
553
+ ),
554
+ ),
555
+ });
556
const validate =
557
options.validate ??
558
Effect.fn("CodexInstallation.validate")(
@@ -613,10 +623,7 @@ export const makeCodexInstallation = Effect.fn("makeCodexInstallation")(function
623
"The existing managed Codex release differs from the official package. Remove it and reinstall.",
624
);
625
yield* ensureEligible();
616
- yield* validate(existing, release.version).pipe(
617
- Effect.scoped,
618
- Effect.timeout("90 seconds"),
619
- );
626
+ yield* validate(existing, release.version).pipe(Effect.scoped, withValidationTimeout);
627
yield* activate();
628
return;
629
}
@@ -710,10 +717,7 @@ export const makeCodexInstallation = Effect.fn("makeCodexInstallation")(function
717
);
718
const executable = yield* fromDirectory(runtime, release.version, release.target);
719
yield* ensureEligible();
713
- yield* validate(executable, release.version).pipe(
714
- Effect.scoped,
715
- Effect.timeout("90 seconds"),
716
- );
720
+ yield* validate(executable, release.version).pipe(Effect.scoped, withValidationTimeout);
721
yield* fs.writeFileString(
722
path.join(runtime, ".install-complete.json"),
723
yield* encodeRecord({
@@ -758,10 +762,7 @@ export const makeCodexInstallation = Effect.fn("makeCodexInstallation")(function
762
function* () {
763
const active = yield* readRecord(activePath, ActiveRelease);
764
const executable = yield* completedRelease(active.version);
761
- yield* validate(executable, executable.version).pipe(
762
- Effect.scoped,
763
- Effect.timeout("90 seconds"),
764
- );
765
+ yield* validate(executable, executable.version).pipe(Effect.scoped, withValidationTimeout);
766
const kept = yield* keptInstall(executable.version);
767
if (kept === null) {
768
yield* SubscriptionRef.update(state, (current) => ({ ...current, ...offer(kept) }));