Skip to content

Commit f283b57

Browse files
committed
fix(server): report Codex archive download timeouts
1 parent 2467e0a commit f283b57

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎apps/server/src/provider/CodexInstallation.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,40 @@ it.effect(
493493
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
494494
);
495495

496+
it.effect.each(["download", "validation"] as const)(
497+
"keeps the timeout message scoped to the download (%s)",
498+
(stage) =>
499+
Effect.gen(function* () {
500+
const fs = yield* FileSystem.FileSystem;
501+
const started = yield* Deferred.make<void>();
502+
const stall = Deferred.succeed(started, undefined).pipe(Effect.andThen(Effect.never));
503+
const h = yield* makeHarness({
504+
platform: "win32",
505+
spawner: makeWindowsTar(fs, []),
506+
...(stage === "download"
507+
? {
508+
body: Stream.concat(
509+
Stream.succeed(archive.subarray(0, 10)),
510+
Stream.fromEffect(stall),
511+
),
512+
}
513+
: { options: { validate: () => stall } }),
514+
});
515+
yield* h.installation.start;
516+
yield* Deferred.await(started);
517+
yield* TestClock.adjust(stage === "download" ? "45 minutes" : "90 seconds");
518+
expect(yield* terminalState(h.installation)).toMatchObject({
519+
phase: "failed",
520+
message:
521+
stage === "download"
522+
? "The Codex download timed out. Retry installation."
523+
: "Could not install Codex. Check disk space and directory access, then try again.",
524+
});
525+
expect(h.downloads()).toBe(1);
526+
expect(yield* h.fs.readDirectory(h.installation.managedDirectory)).toEqual([]);
527+
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
528+
);
529+
496530
it.effect("cancels an in-flight download and cleans the staging directory", () =>
497531
Effect.gen(function* () {
498532
const downloading = yield* Deferred.make<void>();

‎apps/server/src/provider/CodexInstallation.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,14 @@ export const makeCodexInstallation = Effect.fn("makeCodexInstallation")(function
542542
),
543543
Stream.run(fs.sink(archivePath, { flag: "wx", mode: 0o600 })),
544544
Effect.timeout("45 minutes"),
545+
Effect.catchTags({
546+
TimeoutError: (cause) =>
547+
installationError(
548+
"download",
549+
"The Codex download timed out. Retry installation.",
550+
cause,
551+
),
552+
}),
545553
);
546554
if (downloadedBytes !== release.archiveBytes || hash.digest("hex") !== release.sha256)
547555
return yield* installationError(

0 commit comments

Comments
 (0)