Multiplayer agent harness for work.
Ignore git http-backend stdin EPIPE instead of crashing core (#1893)
Regan Bell5dbebac68f67
diff --git a/src/api/routes/deployments.ts b/src/api/routes/deployments.tsindex 48765ccd2..55962944a 100644--- a/src/api/routes/deployments.ts+++ b/src/api/routes/deployments.ts@@ -1154,6 +1154,7 @@ async function runGitHttpBackend(input: {child.stdout.on("data", (d) => stdout.push(Buffer.from(d)));child.stderr.on("data", (d) => stderr.push(Buffer.from(d)));child.on("error", reject);+ child.stdin.on("error", () => {});child.on("close", (code) => {const out = Buffer.concat(stdout);const split = headerEnd(out);diff --git a/test/deploy-git-rw.test.ts b/test/deploy-git-rw.test.tsindex 819f74d0e..471f5c023 100644--- a/test/deploy-git-rw.test.ts+++ b/test/deploy-git-rw.test.ts@@ -307,3 +307,35 @@ test("git-url endpoint: an org-owned deployment is read for a plain member, writawait f.close();}});++test("a garbage push body that git rejects early fails the request without crashing core", async () => {+ const f = fixture();+ const uncaught: unknown[] = [];+ const onUncaught = (error: unknown) => uncaught.push(error);+ process.on("uncaughtException", onUncaught);+ try {+ const d = await f.app.deploy({+ ownerScopeId: scopeId("personal", "U1"),+ createdBy: "U1",+ entrypoint: "node server.js",+ files: [{ path: "server.js", data: "console.log('v1')" }],+ });+ const parsed = new URL(await gitUrl(f.base, d.id, "write"));+ const authorization = `Basic ${Buffer.from(`${decodeURIComponent(parsed.username)}:${decodeURIComponent(parsed.password)}`).toString("base64")}`;+ parsed.username = "";+ parsed.password = "";+ parsed.pathname += "/git-receive-pack";+ const res = await fetch(parsed, {+ method: "POST",+ headers: { authorization, "content-type": "application/x-git-receive-pack-request" },+ body: Buffer.alloc(8_000_000, 0x5a),+ });+ assert.equal(res.status, 500);+ await res.arrayBuffer();+ await new Promise((resolve) => setTimeout(resolve, 200));+ assert.deepEqual(uncaught, []);+ } finally {+ process.off("uncaughtException", onUncaught);+ await f.close();+ }+});