Skip to content

Commit c2f5f45

Browse files
fix(server): read the HTTP status, not the error text, for an unpublished release
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 734acbe commit c2f5f45

2 files changed

Lines changed: 27 additions & 21 deletions

File tree

‎apps/server/src/cloud/pinnedRuntime.test.ts‎

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,27 +162,31 @@ it.layer(NodeServices.layer)("ensurePinnedRuntimeInstalled", (it) => {
162162
const path = yield* Path.Path;
163163
const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-pinned-archive-missing-" });
164164
const checksums = yield* validChecksums;
165-
const error = yield* ensurePinnedRuntimeInstalled({
166-
baseDir,
167-
version,
168-
fs,
169-
path,
170-
platform: "linux",
171-
arch: "x64",
172-
httpClient: HttpClient.make((request) =>
173-
Effect.succeed(
174-
HttpClientResponse.fromWeb(
175-
request,
176-
request.url.endsWith("/SHA256SUMS")
177-
? new Response(checksums)
178-
: new Response("", { status: 404 }),
165+
const failsWith = (status: number) =>
166+
ensurePinnedRuntimeInstalled({
167+
baseDir,
168+
version,
169+
fs,
170+
path,
171+
platform: "linux",
172+
arch: "x64",
173+
httpClient: HttpClient.make((request) =>
174+
Effect.succeed(
175+
HttpClientResponse.fromWeb(
176+
request,
177+
request.url.endsWith("/SHA256SUMS")
178+
? new Response(checksums)
179+
: new Response("", { status }),
180+
),
179181
),
180182
),
181-
),
182-
runner: extractingRunner(fs, path),
183-
validate: () => Effect.die("must not validate a missing archive"),
184-
}).pipe(Effect.flip);
185-
assert.isTrue(isUnpublishedRelease(error));
183+
// "404" in the mirror's path must not read a server error as a missing release.
184+
releaseBaseUrl: "https://updates.example.com/404/t3code",
185+
runner: extractingRunner(fs, path),
186+
validate: () => Effect.die("must not validate a missing archive"),
187+
}).pipe(Effect.flip);
188+
assert.isTrue(isUnpublishedRelease(yield* failsWith(404)));
189+
assert.isFalse(isUnpublishedRelease(yield* failsWith(500)));
186190
}),
187191
);
188192

‎apps/server/src/cloud/pinnedRuntime.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as Schema from "effect/Schema";
99
import * as Option from "effect/Option";
1010
import * as Stream from "effect/Stream";
1111
import * as Semaphore from "effect/Semaphore";
12-
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
12+
import { HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse } from "effect/http";
1313

1414
import {
1515
CLI_RELEASE_CHECKSUMS_FILE,
@@ -264,7 +264,9 @@ const isPinnedRuntimeInstallError = Schema.is(PinnedRuntimeInstallError);
264264
export const isUnpublishedRelease = (error: unknown): error is PinnedRuntimeInstallError =>
265265
isPinnedRuntimeInstallError(error) &&
266266
(error.step.startsWith("finding ") ||
267-
(error.step.startsWith("downloading the t3 release") && String(error.cause).includes("404")));
267+
(error.step.startsWith("downloading the t3 release") &&
268+
HttpClientError.isHttpClientError(error.cause) &&
269+
error.cause.response?.status === 404));
268270

269271
const installPinnedRuntime = Effect.fn("cloud.pinned_runtime.ensure_installed")(function* (
270272
input: PinnedRuntimeInstallInput,

0 commit comments

Comments
 (0)