File tree Expand file tree Collapse file tree
packages/engine/src/services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -252,6 +252,27 @@ describe("getSystemTotalMb", () => {
252252 ) ;
253253 } ) ;
254254
255+ it ( "logs the cgroup-limit notice to stderr, not stdout (keeps --json output clean)" , async ( ) => {
256+ const warn = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } ) ;
257+ const info = vi . spyOn ( console , "info" ) . mockImplementation ( ( ) => { } ) ;
258+ const log = vi . spyOn ( console , "log" ) . mockImplementation ( ( ) => { } ) ;
259+ await withSystemMemoryMocks (
260+ {
261+ files : {
262+ [ CGROUP_V2_MEMORY_MAX_PATH ] : `${ 4096 * BYTES_PER_MIB } ` ,
263+ } ,
264+ } ,
265+ ( { getSystemTotalMb } ) => {
266+ expect ( getSystemTotalMb ( ) ) . toBe ( 4096 ) ;
267+ expect ( warn ) . toHaveBeenCalledTimes ( 1 ) ;
268+ expect ( warn . mock . calls [ 0 ] ?. [ 0 ] ) . toContain ( "[SystemMemory] cgroup memory limit detected" ) ;
269+ // stdout must stay clean so `check --json` output is machine-parseable.
270+ expect ( info ) . not . toHaveBeenCalled ( ) ;
271+ expect ( log ) . not . toHaveBeenCalled ( ) ;
272+ } ,
273+ ) ;
274+ } ) ;
275+
255276 it ( "stays silent when cgroup files are absent" , async ( ) => {
256277 const warn = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } ) ;
257278 await withSystemMemoryMocks ( { } , ( { getSystemTotalMb } ) => {
Original file line number Diff line number Diff line change @@ -93,7 +93,10 @@ function getCgroupLimitMb(): number | null {
9393
9494 _cachedCgroupLimitMb = parseCgroupLimitMb ( v2Content , v1Content ) ;
9595 if ( _cachedCgroupLimitMb !== null ) {
96- console . info (
96+ // stderr, not stdout: this is a diagnostic notice, and commands like `check --json`
97+ // write their machine-readable payload to stdout. A banner on stdout corrupts that
98+ // payload for any JSON consumer (it broke the Video Agent's hyperframes check parse).
99+ console . warn (
97100 `[SystemMemory] cgroup memory limit detected: ${ _cachedCgroupLimitMb } MiB — ` +
98101 `it governs memory-adaptive render behaviour instead of host RAM.` ,
99102 ) ;
You can’t perform that action at this time.
0 commit comments