Files
rea/tests/boundary/cli/captureDecoderHeapDoctor.test.ts
T
morluto 306ed79932 feat(captures): make the HAR/SAZ/qlog decoder heap configurable (#6299)
* feat(captures): make the HAR/SAZ/qlog decoder heap configurable

REA_CAPTURE_DECODER_OLD_GENERATION_MIB keeps the 192 MiB default and
refuses values outside 8 to 16384 MiB instead of falling back.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* fix(captures): defer decoder startup and share one parsed heap

Invalid REA_CAPTURE_DECODER_OLD_GENERATION_MIB threw while CLI commands
were registered, so doctor and help never ran. Build the capture service
only when inspect-web-network-capture runs.

Resolve the heap once in composition and pass that fact to each Node
adapter. Limitation and memory-failure reports use the selected adapter's
heap, so a decoder built with a different environment does not describe
another limit.

Mock captureDecoderProcessMemoryLimitBytes in the Node adapter test so a
Windows Bun host still exercises the unavailable-bound refusal.

Co-authored-by: morluto <morluto@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-10-22 23:52:21 +08:00

29 lines
820 B
TypeScript

import { expect } from "vitest";
import { cliTest } from "../../support/cli/cliFixture.js";
cliTest(
"reports an invalid capture decoder heap from doctor without failing registration",
async ({ cli }) => {
const doctor = await cli.run({
arguments: ["doctor", "--json"],
environment: {
REA_LOG_LEVEL: "silent",
REA_CAPTURE_DECODER_OLD_GENERATION_MIB: "7",
},
});
expect(doctor.exitCode, doctor.stderr).toBe(1);
expect(doctor.stderr).toBe("");
expect(doctor.json).toMatchObject({
healthy: false,
scope_checks: expect.arrayContaining([
expect.objectContaining({
name: "runtime-configuration:REA_CAPTURE_DECODER_OLD_GENERATION_MIB",
ok: false,
classification: "config_drift",
}),
]),
});
},
);