Skip to content

Commit 141e57d

Browse files
fix(ssh): name the full release URL the remote runtime could not download
A failed SHA256SUMS or archive download surfaced only curl's bare HTTP error, or nothing under wget -q, so the connection error never said which release, file, or URL failed. The fetch helper now reports the full URL it was asked for together with the version and exits, and the existing EXIT trap still removes the install lock and staging directory. Takeover of #21170 by jeprecated: the failure message moves into t3_fetch itself, which already holds the URL, instead of a second helper that rebuilt the release directory. The single retained test runs the real runner against a file:// mirror for a missing release and a missing archive and asserts the full URL plus an empty versions directory. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 87bb715 commit 141e57d

2 files changed

Lines changed: 38 additions & 44 deletions

File tree

‎packages/ssh/src/tunnel.test.ts‎

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,43 +1158,39 @@ describe("archive runner script", () => {
11581158
}).pipe(Effect.provide(NodeServices.layer)),
11591159
60_000,
11601160
);
1161-
it.effect.skipIf(windowsHost)("names the release file it could not download", () =>
1162-
Effect.gen(function* () {
1163-
const fs = yield* FileSystem.FileSystem;
1164-
const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-archive-runner-" });
1165-
const releaseBaseUrl = yield* makeMirror(root);
1166-
const home = `${root}/home`;
1167-
yield* fs.makeDirectory(home, { recursive: true });
1168-
const versionsDir = `${home}/.t3/runtime/versions`;
1169-
1170-
const missingRelease = `${root}/run-missing-release.sh`;
1171-
yield* fs.writeFileString(
1172-
missingRelease,
1173-
SshTunnel.buildRemoteT3RunnerScript({ archiveVersion: "9.9.9", releaseBaseUrl }),
1174-
);
1175-
const noRelease = yield* runRunner(home, missingRelease);
1176-
assert.equal(noRelease.exitCode, 1);
1177-
assert.include(
1178-
noRelease.stderr,
1179-
`Could not download SHA256SUMS for t3 9.9.9 from ${releaseBaseUrl}/v9.9.9.`,
1180-
);
1161+
it.effect.skipIf(windowsHost)(
1162+
"names the release file it could not download and leaves no install state",
1163+
() =>
1164+
Effect.gen(function* () {
1165+
const fs = yield* FileSystem.FileSystem;
1166+
const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-archive-runner-" });
1167+
const releaseBaseUrl = yield* makeMirror(root);
1168+
const home = `${root}/home`;
1169+
yield* fs.makeDirectory(home, { recursive: true });
1170+
const failDownload = Effect.fn("failDownload")(function* (version: string) {
1171+
const runner = `${root}/run-${version}.sh`;
1172+
yield* fs.writeFileString(
1173+
runner,
1174+
SshTunnel.buildRemoteT3RunnerScript({ archiveVersion: version, releaseBaseUrl }),
1175+
);
1176+
const result = yield* runRunner(home, runner);
1177+
assert.notEqual(result.exitCode, 0);
1178+
// No install lock, staging directory, or partial install survives the failure.
1179+
assert.deepEqual(yield* fs.readDirectory(`${home}/.t3/runtime/versions`), []);
1180+
return result.stderr;
1181+
});
11811182

1182-
const tarball = (yield* fs.readDirectory(`${root}/mirror/v${archiveVersion}`)).find((name) =>
1183-
name.endsWith(".tar.gz"),
1184-
);
1185-
assert.isDefined(tarball);
1186-
yield* fs.remove(`${root}/mirror/v${archiveVersion}/${tarball}`);
1187-
const missingArchive = `${root}/run-missing-archive.sh`;
1188-
yield* fs.writeFileString(
1189-
missingArchive,
1190-
SshTunnel.buildRemoteT3RunnerScript({ archiveVersion, releaseBaseUrl }),
1191-
);
1192-
const noArchive = yield* runRunner(home, missingArchive);
1193-
assert.equal(noArchive.exitCode, 1);
1194-
assert.include(noArchive.stderr, `Could not download ${tarball} for t3 ${archiveVersion}`);
1195-
assert.isFalse(yield* fs.exists(`${versionsDir}/.${archiveVersion}.install.lock`));
1196-
assert.isFalse(yield* fs.exists(`${versionsDir}/${archiveVersion}`));
1197-
}).pipe(Effect.provide(NodeServices.layer)),
1183+
const noRelease = yield* failDownload("9.9.9");
1184+
assert.include(noRelease, `${releaseBaseUrl}/v9.9.9/SHA256SUMS`);
1185+
1186+
const release = `${root}/mirror/v${archiveVersion}`;
1187+
const tarball = (yield* fs.readDirectory(release)).find((name) => name.endsWith(".tar.gz"));
1188+
assert.isDefined(tarball);
1189+
yield* fs.remove(`${release}/${tarball}`);
1190+
const noArchive = yield* failDownload(archiveVersion);
1191+
assert.include(noArchive, `${releaseBaseUrl}/v${archiveVersion}/${tarball}`);
1192+
}).pipe(Effect.provide(NodeServices.layer)),
1193+
60_000,
11981194
);
11991195
});
12001196

‎packages/ssh/src/tunnel.ts‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -513,19 +513,17 @@ if ! t3_runtime_ready; then
513513
T3_ARCHIVE="t3-$T3_ARCHIVE_VERSION-$T3_PLATFORM-$T3_ARCH.tar.gz"
514514
T3_STAGING="$(mktemp -d "$HOME/.t3/runtime/versions/.staging-XXXXXX")"
515515
trap 'rm -rf "$T3_STAGING" "$T3_LOCK"' EXIT
516+
# curl's HTTP error omits the URL and wget -q prints nothing, so name what was not fetched.
516517
t3_fetch() {
517-
if command -v curl >/dev/null 2>&1; then curl -fsSL --connect-timeout 30 --max-time "$3" "$1" -o "$2"
518-
elif command -v wget >/dev/null 2>&1; then wget -q --timeout=30 --tries=1 "$1" -O "$2"
518+
if command -v curl >/dev/null 2>&1; then curl -fsSL --connect-timeout 30 --max-time "$3" "$1" -o "$2" && return
519+
elif command -v wget >/dev/null 2>&1; then wget -q --timeout=30 --tries=1 "$1" -O "$2" && return
519520
else printf 'Remote host needs curl or wget to download %s.\\n' "$T3_ARCHIVE" >&2; exit 1
520521
fi
521-
}
522-
# curl's HTTP error omits the URL and wget -q prints nothing, so name what was not fetched.
523-
t3_fetch_failed() {
524-
printf 'Could not download %s for t3 %s from %s/v%s. Check that this release exists and the host can reach it.\\n' "$1" "$T3_ARCHIVE_VERSION" "$T3_RELEASE_BASE_URL" "$T3_ARCHIVE_VERSION" >&2
522+
printf 'Could not download %s for t3 %s. Check that this release exists and the host can reach it.\\n' "$1" "$T3_ARCHIVE_VERSION" >&2
525523
exit 1
526524
}
527-
t3_fetch "$T3_RELEASE_BASE_URL/v$T3_ARCHIVE_VERSION/SHA256SUMS" "$T3_STAGING/SHA256SUMS" @@T3_ARCHIVE_CHECKSUMS_SECONDS@@ || t3_fetch_failed SHA256SUMS
528-
t3_fetch "$T3_RELEASE_BASE_URL/v$T3_ARCHIVE_VERSION/$T3_ARCHIVE" "$T3_STAGING/$T3_ARCHIVE" @@T3_ARCHIVE_DOWNLOAD_SECONDS@@ || t3_fetch_failed "$T3_ARCHIVE"
525+
t3_fetch "$T3_RELEASE_BASE_URL/v$T3_ARCHIVE_VERSION/SHA256SUMS" "$T3_STAGING/SHA256SUMS" @@T3_ARCHIVE_CHECKSUMS_SECONDS@@
526+
t3_fetch "$T3_RELEASE_BASE_URL/v$T3_ARCHIVE_VERSION/$T3_ARCHIVE" "$T3_STAGING/$T3_ARCHIVE" @@T3_ARCHIVE_DOWNLOAD_SECONDS@@
529527
T3_EXPECTED="$(grep " \\*\\{0,1\\}$T3_ARCHIVE$" "$T3_STAGING/SHA256SUMS" | cut -d' ' -f1)"
530528
if command -v sha256sum >/dev/null 2>&1; then
531529
T3_ACTUAL="$(sha256sum "$T3_STAGING/$T3_ARCHIVE" | cut -d' ' -f1)"

0 commit comments

Comments
 (0)