Tags: Query-Doctor/analyzer
Tags
fix(runner): register close listener before the for-await loop If pgbadger exits while processQuery is still awaited in the last loop iteration, the 'close' event fires and is lost. The promise created after the loop then never resolves, main() hangs, and the runner kills the process with SIGPIPE (exit code 13). Fix: create the childClosed promise before the loop so the listener is always registered before the event can fire. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix(runner): prevent process.stderr from closing when pgbadger exits
child.stderr.pipe(process.stderr) uses { end: true } by default, which
calls process.stderr.end() when pgbadger's stderr stream closes. Any
subsequent write to stderr (reporter, pool logs) then triggers SIGPIPE,
killing the process before reporter.report() runs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chore: add better logging for when analysis fails for a single query
fix: set allowExitOnIdle on source pool to prevent hang after run pg-pool keeps idle connections and their timers ref'd by default, which prevents Node from exiting even after pool.end() resolves. The underlying TCP sockets continue draining for ~15s (matching idleTimeoutMillis), keeping the event loop alive. allowExitOnIdle unrefs idle connections so they don't block exit. Adds integration tests that spawn child processes to verify: - Idle connections don't block process exit - Explicit pool close exits 0, not SIGPIPE (13) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: close db pool instead of process.exit() to prevent SIGPIPE process.exit() synchronously kills the process before buffered stdout flushes through the CI pipe, causing SIGPIPE (exit code 13). Instead, close the pg Pool so the event loop drains naturally and Node exits 0 on its own once all I/O has flushed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PreviousNext