mirror of
https://github.com/github/codeql-action.git
synced 2026-10-24 14:47:13 +00:00
A network error such as `ECONNRESET` while streaming the download and extraction of the CodeQL bundle terminated the `init` Action rather than falling back to downloading the bundle before extracting it, since no `error` listener was attached to the request returned by `https.get`. Also pipe the response into `tar` using `stream.pipeline` so that errors on the response itself are surfaced and `tar`'s standard input is closed, and abort the request if it stalls. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
34 lines
826 B
TypeScript
34 lines
826 B
TypeScript
import * as path from "path";
|
|
import * as stream from "stream";
|
|
|
|
import test from "ava";
|
|
|
|
import { getRunnerLogger } from "./logging";
|
|
import { extractTarZst } from "./tar";
|
|
import { setupTests } from "./testing-utils";
|
|
import { withTmpDir } from "./util";
|
|
|
|
setupTests(test);
|
|
|
|
test("extractTarZst rejects if the input stream errors", async (t) => {
|
|
await withTmpDir(async (tmpDir) => {
|
|
const archive = new stream.PassThrough();
|
|
const promise = extractTarZst(
|
|
archive,
|
|
path.join(tmpDir, "dest"),
|
|
{ type: "gnu", version: "1.34" },
|
|
getRunnerLogger(true),
|
|
);
|
|
|
|
archive.destroy(
|
|
Object.assign(new Error("socket hang up"), {
|
|
code: "ECONNRESET",
|
|
}),
|
|
);
|
|
|
|
await t.throwsAsync(promise, {
|
|
message: /Error while downloading and extracting tar/,
|
|
});
|
|
});
|
|
});
|