test(firmware): keep producer fixtures within supported Node limits (#7048)

* test(firmware): bound fixture hashing and avoid Node startup warnings

* test(firmware): apply the Wasm flag only on Node 22
This commit is contained in:
RRFZ authored and GitHub committed 2026-10-29 02:42:21 +08:00
1 parent 8f9af920ef
commit b75419b61e
2 files changed
+22 -3

No files matched your search

+19 -3
View File
@@ -1,8 +1,8 @@
import { createHash } from "node:crypto";
import { createReadStream } from "node:fs";
import {
chmod,
mkdir,
open,
readFile,
truncate,
writeFile,
@@ -146,8 +146,24 @@ if (args.includes("--version")) {
const oversized = 128 * 1024 * 1024 + 1;
await truncate(child, oversized);
const oversizedDigest = createHash("sha256");
for await (const chunk of createReadStream(child))
oversizedDigest.update(chunk);
// Reuse one buffer under the real engine's address-space ceiling instead
// of depending on when Node collects the stream's retired chunk buffers.
const source = await open(child, "r");
try {
const buffer = Buffer.alloc(64 * 1024);
for (;;) {
const { bytesRead } = await source.read(
buffer,
0,
buffer.length,
null,
);
if (bytesRead === 0) break;
oversizedDigest.update(buffer.subarray(0, bytesRead));
}
} finally {
await source.close();
}
const oversizedHash = oversizedDigest.digest("hex");
const nestedUnknownRecords = [
{
+3
View File
@@ -22,6 +22,9 @@ export const firmwareFixture = async (mode = "normal", banner?: string) => {
process.execPath,
// Keep the synthetic JS producer within the real engines' address-space ceiling.
"--jitless",
// Node 22 warns when jitless implicitly disables Wasm. Newer releases do
// not need this flag, and Node 26 no longer accepts it.
...(process.versions.node.startsWith("22.") ? ["--no-expose-wasm"] : []),
fileURLToPath(new URL("./producer.mjs", import.meta.url)),
engine,
]