mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 23:03:09 +00:00
fix(engine): emit SystemMemory cgroup notice to stderr, not stdout (#2520)
This commit is contained in:
@@ -252,6 +252,27 @@ describe("getSystemTotalMb", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("logs the cgroup-limit notice to stderr, not stdout (keeps --json output clean)", async () => {
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
const info = vi.spyOn(console, "info").mockImplementation(() => {});
|
||||
const log = vi.spyOn(console, "log").mockImplementation(() => {});
|
||||
await withSystemMemoryMocks(
|
||||
{
|
||||
files: {
|
||||
[CGROUP_V2_MEMORY_MAX_PATH]: `${4096 * BYTES_PER_MIB}`,
|
||||
},
|
||||
},
|
||||
({ getSystemTotalMb }) => {
|
||||
expect(getSystemTotalMb()).toBe(4096);
|
||||
expect(warn).toHaveBeenCalledTimes(1);
|
||||
expect(warn.mock.calls[0]?.[0]).toContain("[SystemMemory] cgroup memory limit detected");
|
||||
// stdout must stay clean so `check --json` output is machine-parseable.
|
||||
expect(info).not.toHaveBeenCalled();
|
||||
expect(log).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it("stays silent when cgroup files are absent", async () => {
|
||||
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
await withSystemMemoryMocks({}, ({ getSystemTotalMb }) => {
|
||||
|
||||
@@ -93,7 +93,10 @@ function getCgroupLimitMb(): number | null {
|
||||
|
||||
_cachedCgroupLimitMb = parseCgroupLimitMb(v2Content, v1Content);
|
||||
if (_cachedCgroupLimitMb !== null) {
|
||||
console.info(
|
||||
// stderr, not stdout: this is a diagnostic notice, and commands like `check --json`
|
||||
// write their machine-readable payload to stdout. A banner on stdout corrupts that
|
||||
// payload for any JSON consumer (it broke the Video Agent's hyperframes check parse).
|
||||
console.warn(
|
||||
`[SystemMemory] cgroup memory limit detected: ${_cachedCgroupLimitMb} MiB — ` +
|
||||
`it governs memory-adaptive render behaviour instead of host RAM.`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user