Skip to content

Commit 0fa18ad

Browse files
fix(install): name the archive when its download fails (pingdotgg#35854)
1 parent edd6fc3 commit 0fa18ad

2 files changed

Lines changed: 53 additions & 1 deletion

File tree

‎scripts/install.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ else
248248
fi
249249
expected="$(grep " \*\{0,1\}${archive}\$" "${staging}/SHA256SUMS" | cut -d' ' -f1)"
250250
[ -n "$expected" ] || fail "t3 ${version} has no release archive for ${platform}-${arch}"
251-
download "${base_url}/v${version}/${archive}" "${staging}/${archive}"
251+
download "${base_url}/v${version}/${archive}" "${staging}/${archive}" || fail "could not download ${archive}"
252252

253253
step "Verifying the download..."
254254
actual="$(checksum "${staging}/${archive}")"

‎scripts/install.test.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,58 @@ describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("installer chan
130130
});
131131
});
132132

133+
// regression: #35834
134+
describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")(
135+
"installer archive download",
136+
() => {
137+
it("names the archive when it returns 404", async () => {
138+
const root = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-install-archive-"));
139+
const arch = HostProcess.Architecture.defaultValue() === "arm64" ? "arm64" : "x64";
140+
const archive = `t3-1.2.3-linux-${arch}.tar.gz`;
141+
const server = NodeHttp.createServer((request, response) => {
142+
if (request.url === "/v1.2.3/SHA256SUMS")
143+
return response.end(`${"0".repeat(64)} ${archive}\n`);
144+
response.writeHead(404).end();
145+
});
146+
try {
147+
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
148+
const address = server.address();
149+
if (!address || typeof address === "string") throw new Error("Expected a TCP listener");
150+
const { code, output } = await new Promise<{ code: number | null; output: string }>(
151+
(resolve, reject) => {
152+
const child = NodeChildProcess.spawn(
153+
"sh",
154+
[NodePath.resolve(import.meta.dirname, "install.sh")],
155+
{
156+
env: {
157+
...process.env,
158+
T3CODE_CHANNEL: "",
159+
T3CODE_VERSION: "1.2.3",
160+
T3CODE_HOME: NodePath.join(root, "home"),
161+
T3CODE_INSTALL_BIN_DIR: NodePath.join(root, "bin"),
162+
T3CODE_RELEASE_BASE_URL: `http://127.0.0.1:${address.port}`,
163+
},
164+
stdio: ["ignore", "pipe", "pipe"],
165+
},
166+
);
167+
let output = "";
168+
child.stdout.on("data", (chunk: Buffer) => (output += chunk.toString()));
169+
child.stderr.on("data", (chunk: Buffer) => (output += chunk.toString()));
170+
child.on("error", reject);
171+
child.on("close", (code) => resolve({ code, output }));
172+
},
173+
);
174+
expect(code, output).not.toBe(0);
175+
expect(output).toMatch(new RegExp(`t3 install: .*${archive.replaceAll(".", "\\.")}`));
176+
} finally {
177+
server.closeAllConnections();
178+
await new Promise<void>((resolve) => server.close(() => resolve()));
179+
await NodeFSP.rm(root, { recursive: true, force: true });
180+
}
181+
});
182+
},
183+
);
184+
133185
/** Runs an installer for a version that is already unpacked, so only the t3 command step runs. */
134186
async function installOver(input: {
135187
readonly script: "install.sh" | "install.ps1";

0 commit comments

Comments
 (0)