fix(analyze): add explicit heap increase guidance on respawn OOM
Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/27c51b9a-8721-4bb1-a899-3d076ff96da6 Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
This commit is contained in:
co-authored by
magyargergo
parent
fffeb4a87a
commit
c17f0014ee
@@ -73,6 +73,14 @@ const HEAP_FLAG = `--max-old-space-size=${HEAP_MB}`;
|
||||
const STACK_KB = 4096;
|
||||
const STACK_FLAG = `--stack-size=${STACK_KB}`;
|
||||
|
||||
/**
|
||||
* Heuristic for "child re-exec likely died from V8 OOM".
|
||||
*
|
||||
* `execFileSync(..., { stdio: 'inherit' })` does not give us structured
|
||||
* OOM metadata, but on Linux/macOS Node commonly exits with status 134
|
||||
* and/or SIGABRT after a fatal heap exhaustion. We use those signatures
|
||||
* to decide when to print heap-increase guidance for the user.
|
||||
*/
|
||||
const childProcessLikelyOom = (err: unknown): boolean => {
|
||||
if (!err || typeof err !== 'object') return false;
|
||||
const e = err as { status?: unknown; signal?: unknown };
|
||||
|
||||
@@ -55,7 +55,12 @@ describe('analyzeCommand heap respawn', () => {
|
||||
await analyzeCommand(undefined, {});
|
||||
|
||||
expect(process.exitCode).toBe(134);
|
||||
expect(cap.records().some((r) => r.msg.includes('Analysis likely ran out of memory.'))).toBe(true);
|
||||
const oomGuidance = cap.records().find((r) => r.msg.includes('Analysis likely ran out of memory.'));
|
||||
expect(oomGuidance).toBeDefined();
|
||||
expect(oomGuidance!.msg).toContain('NODE_OPTIONS="--max-old-space-size=24576"');
|
||||
expect(oomGuidance!.msg).toContain(
|
||||
'(Windows: set NODE_OPTIONS=--max-old-space-size=24576 && gitnexus analyze ...)',
|
||||
);
|
||||
cap.restore();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user