From 8090eeb839c0f43e99a86efaa8cb5ea2329b560b Mon Sep 17 00:00:00 2001 From: Libby Date: Wed, 11 Nov 2026 06:26:21 +0000 Subject: [PATCH] cultmesh-browser test: make the unallocatable-size refusal certain on hosts that overcommit The 64 TiB manifest allocated lazily on the forge runner, so the reader went on to fetch and the test saw a network error. The test now makes Uint8Array refuse sizes past 2^40 for its duration. Co-Authored-By: Claude Sonnet 5.5 --- packages/cultmesh-browser/test/content.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/cultmesh-browser/test/content.test.ts b/packages/cultmesh-browser/test/content.test.ts index d4ec4d6e..2f77904e 100644 --- a/packages/cultmesh-browser/test/content.test.ts +++ b/packages/cultmesh-browser/test/content.test.ts @@ -567,8 +567,14 @@ test("a size the runtime cannot allocate is too-large in both exports, not a Ran const count = 2 ** 15; const huge = { ...manifest, sizeBytes: count * int32Max, chunks: Array.from({ length: count }, (_, index) => ({ ...manifest.chunks[0]!, offset: index * int32Max, sizeBytes: int32Max })) }; const server = double(() => { throw new Error("no request expected"); }); - await assert.rejects(fetchVerifiedContent(ENDPOINT, huge, { fetch: server.fetch, maxBytes: size }), codeOf("too-large")); - await assert.rejects(fetchVerifiedChunk(ENDPOINT, manifest.chunks[0]!.chunkHash!, size, { fetch: server.fetch, maxBytes: size }), codeOf("too-large")); + // a host with overcommit hands out 64 TiB lazily, so the refusal is made certain: the runtime cannot allocate it + const native = globalThis.Uint8Array; + const refusing = new Proxy(native, { construct: (target, args, receiver) => { if (typeof args[0] === "number" && args[0] > 2 ** 40) throw new RangeError("Array buffer allocation failed"); return Reflect.construct(target, args, receiver); } }); + globalThis.Uint8Array = refusing; + try { + await assert.rejects(fetchVerifiedContent(ENDPOINT, huge, { fetch: server.fetch, maxBytes: size }), codeOf("too-large")); + await assert.rejects(fetchVerifiedChunk(ENDPOINT, manifest.chunks[0]!.chunkHash!, size, { fetch: server.fetch, maxBytes: size }), codeOf("too-large")); + } finally { globalThis.Uint8Array = native; } assert.equal(server.calls.length, 0); });