[object Object]

← back to Cncp Failure Collector

fix(collector): bump execSync maxBuffer to prevent pm2 jlist ENOBUFS death

bba7324de003a208daccee5eefb7670ab8d53e9f · 2026-05-29 09:14:38 -0700 · SteveStudio2

The mac2 collector died 2026-05-15 11:37 in a 'pm2 jlist failed: spawnSync
/bin/sh ENOBUFS' spiral — pm2 jlist output exceeded execSync's 1MB default
maxBuffer on a busy box, so readPm2() threw every cycle and the process
exited (never resurrected, froze the CNCP mac2 failure ledger for 14 days).
Set maxBuffer 64MB on pm2 jlist and 16MB on the log-tail call.

Files touched

Diff

commit bba7324de003a208daccee5eefb7670ab8d53e9f
Author: SteveStudio2 <stevestudio2@SteveStacStudio.lan>
Date:   Fri May 29 09:14:38 2026 -0700

    fix(collector): bump execSync maxBuffer to prevent pm2 jlist ENOBUFS death
    
    The mac2 collector died 2026-05-15 11:37 in a 'pm2 jlist failed: spawnSync
    /bin/sh ENOBUFS' spiral — pm2 jlist output exceeded execSync's 1MB default
    maxBuffer on a busy box, so readPm2() threw every cycle and the process
    exited (never resurrected, froze the CNCP mac2 failure ledger for 14 days).
    Set maxBuffer 64MB on pm2 jlist and 16MB on the log-tail call.
---
 index.js | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/index.js b/index.js
index e4ede1d..388da8d 100644
--- a/index.js
+++ b/index.js
@@ -115,7 +115,10 @@ async function postTask(payload) {
 
 function readPm2() {
   try {
-    const out = execSync('pm2 jlist', { encoding: 'utf-8', timeout: 8_000 });
+    // maxBuffer: pm2 jlist embeds full pm2_env per process; on a busy box the
+    // JSON blows past execSync's 1MB default -> ENOBUFS -> collector dies
+    // (root cause of the 2026-05-15 mac2 collector death). 64MB = ample headroom.
+    const out = execSync('pm2 jlist', { encoding: 'utf-8', timeout: 8_000, maxBuffer: 64 * 1024 * 1024 });
     return JSON.parse(out);
   } catch (e) {
     log('pm2 jlist failed:', e.message);
@@ -125,7 +128,7 @@ function readPm2() {
 
 function tailFile(p, lines = 20) {
   try {
-    return execSync(`tail -n ${lines} ${JSON.stringify(p)}`, { encoding: 'utf-8', timeout: 3_000 });
+    return execSync(`tail -n ${lines} ${JSON.stringify(p)}`, { encoding: 'utf-8', timeout: 3_000, maxBuffer: 16 * 1024 * 1024 });
   } catch { return ''; }
 }
 

← b843af5 docs: fix misleading comment + variable name (no journalctl;  ·  back to Cncp Failure Collector  ·  Apply benign-noise filter in scanLinuxLogs so nginx TLS-prob 0d7a271 →