Skip to content

Commit f52f8b0

Browse files
binjamshidclaude
andcommitted
fix(server): provider updates no longer time out mid-download
`claude update` downloads a ~300 MB native binary and prints nothing while it does. On a slow link that takes longer than the five-minute update timeout, so T3 Code killed it mid-download. Claude's updater left a 0-byte version file behind and the next update treated it as installed, reporting success while the provider stayed outdated. Raise the update timeout to 30 minutes and name the limit in the timeout message. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 79f1fad commit f52f8b0

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
} from "@t3tools/contracts";
88
import { ServerProviderUpdateError } from "@t3tools/contracts";
99
import * as Cause from "effect/Cause";
10+
import * as Deferred from "effect/Deferred";
1011
import * as Effect from "effect/Effect";
1112
import * as Exit from "effect/Exit";
1213
import * as Fiber from "effect/Fiber";
@@ -15,6 +16,7 @@ import * as Ref from "effect/Ref";
1516
import * as Schema from "effect/Schema";
1617
import * as Sink from "effect/Sink";
1718
import * as Stream from "effect/Stream";
19+
import * as TestClock from "effect/testing/TestClock";
1820
import { HttpClient, HttpClientResponse } from "effect/http";
1921
import { ChildProcessSpawner } from "effect/process";
2022
import * as HostProcess from "@t3tools/shared/HostProcess";
@@ -755,6 +757,41 @@ describe("providerMaintenanceRunner", () => {
755757
),
756758
);
757759

760+
// A native updater such as `claude update` downloads a ~300 MB binary and
761+
// prints nothing while it does. Killed mid-download, it leaves a truncated
762+
// binary behind that later updates mistake for an install.
763+
it.effect.each([
764+
{ runFor: "6 minutes", status: "succeeded", message: "Provider updated." },
765+
{ runFor: "31 minutes", status: "failed", message: "Update timed out after 30 minutes." },
766+
] as const)("lets a slow installer run for $runFor", ({ runFor, status, message }) => {
767+
const started = Deferred.makeUnsafe<void>();
768+
return Effect.gen(function* () {
769+
const { registry } = yield* makeRegistry(baseNativeCliProvider);
770+
const updater = yield* makeTestRunner(registry);
771+
772+
const update = yield* updater.updateProvider(NATIVE_CLI_DRIVER).pipe(Effect.forkScoped);
773+
yield* Deferred.await(started);
774+
yield* TestClock.adjust(runFor);
775+
const result = yield* Fiber.join(update);
776+
777+
assert.strictEqual(result.providers[0]?.updateState?.status, status);
778+
assert.strictEqual(result.providers[0]?.updateState?.message, message);
779+
}).pipe(
780+
Effect.provide(
781+
Layer.mergeAll(
782+
layerNonWindowsPlatform,
783+
layerLatestVersionHttpClient("1.0.0"),
784+
layerMockSpawner(() => ({
785+
exitCode: Deferred.succeed(started, undefined).pipe(
786+
Effect.andThen(Effect.sleep(runFor)),
787+
Effect.as(ChildProcessSpawner.ExitCode(0)),
788+
),
789+
})),
790+
),
791+
),
792+
);
793+
});
794+
758795
it.effect("prevents concurrent updates for the same provider", () => {
759796
const startedLatch: { resolve: () => void } = { resolve: () => {} };
760797
const releaseLatch: { resolve: () => void } = { resolve: () => {} };

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ import type { ProviderMaintenanceCapabilities } from "@t3tools/provider-core/ser
4141
import { collectUint8StreamText } from "@t3tools/provider-core/server/collectStreamText";
4242
const isServerProviderUpdateError = Schema.is(ServerProviderUpdateError);
4343

44-
const UPDATE_TIMEOUT_MS = 5 * 60_000;
44+
// Native updaters (`claude update`) download a ~300 MB binary without printing
45+
// progress, and killing one mid-download leaves a truncated binary that the
46+
// next run treats as installed. Allow a slow connection to finish.
47+
const UPDATE_TIMEOUT_MINUTES = 30;
48+
const UPDATE_TIMEOUT_MS = UPDATE_TIMEOUT_MINUTES * 60_000;
4549
const UPDATE_OUTPUT_MAX_BYTES = 10_000;
4650
// Sample installer output because every progress update resends the provider list to all clients.
4751
const UPDATE_PROGRESS_INTERVAL = Duration.seconds(1);
@@ -259,7 +263,7 @@ function lastOutputLine(result: ProviderMaintenanceCommandResult): string | null
259263

260264
function failureMessage(result: ProviderMaintenanceCommandResult): string {
261265
if (result.timedOut) {
262-
return "Update timed out.";
266+
return `Update timed out after ${UPDATE_TIMEOUT_MINUTES} minutes.`;
263267
}
264268
const summary =
265269
result.exitCode !== null && result.exitCode !== 0

0 commit comments

Comments
 (0)