Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(desktop): don't wait for an oversized 401 body to finish cancelling
AdityaUmale34f03d8f6267
diff --git a/electron/server-probe.mjs b/electron/server-probe.mjsindex 8b56411ba7..f3f2874984 100644--- a/electron/server-probe.mjs+++ b/electron/server-probe.mjs@@ -49,7 +49,7 @@ async function readSmallBody(response) {if (done) break;size += value.byteLength;if (size > REFUSAL_MAX_BYTES) {- await reader.cancel().catch(() => {});+ void reader.cancel().catch(() => {});return null;}chunks.push(value);@@ -60,7 +60,7 @@ async function readSmallBody(response) {/** A desktop app's companion refusal is a small JSON body; anything larger or not shaped like it isn't one. */async function isDesktopAppRefusal(response) {if (Number(response.headers?.get?.("content-length")) > REFUSAL_MAX_BYTES) {- await response.body?.cancel().catch(() => {});+ void response.body?.cancel().catch(() => {});return false;}const text = await readSmallBody(response).catch(() => null);diff --git a/electron/server-probe.node-test.mjs b/electron/server-probe.node-test.mjsindex 79aca92245..8f5b9c1da0 100644--- a/electron/server-probe.node-test.mjs+++ b/electron/server-probe.node-test.mjs@@ -112,3 +112,13 @@ test("a 401 whose Content-Length is over the refusal limit is cancelled unread",assert.equal(cancelled, true);assert.equal(pulled, 0);});++test("a 401 body whose cancellation never settles does not hold up the probe", async () => {+ for (const headers of [{ "content-length": "1000000" }, {}]) {+ const stuck = () => new Response(new ReadableStream({+ pull(controller) { controller.enqueue(new Uint8Array(1_024).fill(120)); },+ cancel() { return new Promise(() => {}); },+ }, { highWaterMark: 0 }), { status: 401, headers });+ assert.equal((await probeServer({ address: "maus.example.com", fetch: fakeFetch({ "https://maus.example.com": stuck }).fetch })).problem, "notMausBot");+ }+});