The best way to control Claude Code, Codex and more from any computer or phone
fix(server): failed updates report download diagnostics (#33239)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Tanav Poswal committed
Nov 10, 2026 at 13:49 UTC
633438d54f17b99f73f1a09466ecbe4a6aa0d545
3 files changed
+69
-13
apps/server/src/cloud/pinnedRuntime.ts
+9
@@ -71,6 +71,8 @@ export class PinnedRuntimeInstallError extends Schema.TaggedError<PinnedRuntimeI
71
exitCode: Schema.optional(Schema.Number),
72
stdoutLength: Schema.optional(Schema.Number),
73
stderrLength: Schema.optional(Schema.Number),
74
+ httpStatus: Schema.optional(Schema.Number),
75
+ downloadHost: Schema.optional(Schema.String),
76
cause: Schema.optional(Schema.Defect()),
77
},
78
) {
@@ -163,6 +165,13 @@ const fetchReleaseAsset = Effect.fn("cloud.pinned_runtime.fetch_release_asset")(
165
(cause) =>
166
new PinnedRuntimeInstallError({
167
step: cause._tag === "TimeoutError" ? `${step} (timed out)` : step,
168
+ httpStatus:
169
+ HttpClientError.isHttpClientError(cause) && cause.reason._tag === "StatusCodeError"
170
+ ? cause.reason.response.status
171
+ : undefined,
172
+ downloadHost: URL.parse(
173
+ HttpClientError.isHttpClientError(cause) ? cause.request.url : url,
174
+ )?.host,
175
cause,
176
}),
177
),
apps/server/src/cloud/selfUpdate.test.ts
+39
-3
@@ -11,7 +11,7 @@ import * as Layer from "effect/Layer";
11
import * as Path from "effect/Path";
12
import * as Stream from "effect/Stream";
13
import * as TestClock from "effect/testing/TestClock";
14
-import { HttpClient, HttpClientResponse } from "effect/http";
14
+import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
15
import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
16
17
import packageJson from "../../package.json" with { type: "json" };
@@ -30,6 +30,7 @@ interface HarnessOptions {
30
readonly preflightDuration?: Duration.Input;
31
readonly preflightStarted?: Deferred.Deferred<void>;
32
readonly beforeDownload?: Effect.Effect<void>;
33
+ readonly httpClient?: HttpClient.HttpClient;
34
readonly requestUpdate?: ServiceLauncherClient.ServiceLauncherClient["Service"]["requestUpdate"];
35
readonly desktopAppUpdate?: DesktopAppUpdate.DesktopAppUpdate["Service"];
36
readonly policy?: ManagedPolicyDocument;
@@ -145,7 +146,7 @@ const makeHarness = Effect.fn("test.make_self_update_harness")(function* (
146
),
147
Effect.provideService(
148
HttpClient.HttpClient,
148
- releaseHttpClient(order, urls, options.beforeDownload),
149
+ options.httpClient ?? releaseHttpClient(order, urls, options.beforeDownload),
150
),
151
Effect.provideService(HostProcess.Platform, "linux"),
152
Effect.provideService(HostProcess.Architecture, "x64"),
@@ -156,10 +157,45 @@ const makeHarness = Effect.fn("test.make_self_update_harness")(function* (
157
),
158
),
159
);
159
- return { selfUpdate, order, urls };
160
+ return { selfUpdate, order, urls, baseDir };
161
});
162
163
it.layer(NodeServices.layer)("server self update", (it) => {
164
+ it.effect.each([
165
+ { asset: "checksums", status: 504 },
166
+ { asset: "archive", status: 503 },
167
+ { asset: "checksums", status: 403 },
168
+ ])("reports an HTTP $status downloading $asset and allows retry", ({ asset, status }) =>
169
+ Effect.gen(function* () {
170
+ let failDownload = true;
171
+ const { selfUpdate, order, baseDir } = yield* makeHarness({
172
+ httpClient: releaseHttpClient([], []).pipe(
173
+ HttpClient.transform((response, request) =>
174
+ failDownload && request.url.endsWith("/SHA256SUMS") === (asset === "checksums")
175
+ ? Effect.succeed(
176
+ HttpClientResponse.fromWeb(
177
+ HttpClientRequest.get("https://user:password@cdn.example/private?token=secret"),
178
+ new Response("private response body", { status }),
179
+ ),
180
+ )
181
+ : response,
182
+ ),
183
+ ),
184
+ });
185
+ const error = yield* selfUpdate.update({ targetVersion: "1.1.0" }).pipe(Effect.flip);
186
+ expect(error.reason).toBe(
187
+ `Could not prepare t3@1.1.0 while downloading the t3 release ${asset} (HTTP ${status} from cdn.example).`,
188
+ );
189
+ expect(order).toEqual([]);
190
+ const fs = yield* FileSystem.FileSystem;
191
+ const path = yield* Path.Path;
192
+ expect(yield* fs.readDirectory(path.join(baseDir, "runtime", "versions"))).toEqual([]);
193
+ failDownload = false;
194
+ expect((yield* selfUpdate.update({ targetVersion: "1.1.0" })).updateId).toBe("launcher-id");
195
+ expect(order).toEqual(["extract", "preflight", "accept"]);
196
+ }),
197
+ );
198
+
199
// regression: #5181 make remote updates rollback-safe
200
it.effect("rejects invalid versions and desktop-managed servers before staging", () =>
201
Effect.gen(function* () {
apps/server/src/cloud/selfUpdate.ts
+21
-10
@@ -282,16 +282,27 @@ export const make = Effect.fn("cloud.server_self_update.make")(function* () {
282
),
283
),
284
}).pipe(
285
- Effect.mapError((error) =>
286
- error._tag === "PinnedRuntimePreflightBlockedError"
287
- ? failWith(error.reason, error)
288
- : mirror !== undefined && isUnpublishedRelease(error)
289
- ? failWith(
290
- `${mirror.organization}'s update mirror has no t3@${targetVersion} for this machine.`,
291
- error,
292
- )
293
- : failWith(`Could not prepare t3@${targetVersion}.`, error),
294
- ),
285
+ Effect.mapError((error) => {
286
+ if (error._tag === "PinnedRuntimePreflightBlockedError") {
287
+ return failWith(error.reason, error);
288
+ }
289
+ if (mirror !== undefined && isUnpublishedRelease(error)) {
290
+ return failWith(
291
+ `${mirror.organization}'s update mirror has no t3@${targetVersion} for this machine.`,
292
+ error,
293
+ );
294
+ }
295
+ const downloadFailure = [
296
+ error.httpStatus === undefined ? undefined : `HTTP ${error.httpStatus}`,
297
+ error.downloadHost === undefined ? undefined : `from ${error.downloadHost}`,
298
+ ]
299
+ .filter((part) => part !== undefined)
300
+ .join(" ");
301
+ return failWith(
302
+ `Could not prepare t3@${targetVersion} while ${error.step}${downloadFailure ? ` (${downloadFailure})` : ""}.`,
303
+ error,
304
+ );
305
+ }),
306
);
307
308
yield* reportProgress("installing");