chore(run/core): Optimize service initialization tracking to reduce startup overhead in health status reporting

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Quinn Ftw 2026-02-04 21:02:07 -08:00
parent fc23527a82
commit 8b04641b7a
2 changed files with 61 additions and 8 deletions

View file

@ -139,11 +139,43 @@ const SUPPRESS_PATTERNS = [
/DeprecationWarning/,
// Suppress verbose axios/network object dumps
/\[Symbol\(/,
/Symbol\(\w+\)/,
/_idleTimeout:/,
/_idlePrev:/,
/_idleNext:/,
/_idleStart:/,
/_onTimeout:/,
/_timerArgs:/,
/_repeat:/,
/_destroyed:/,
/kOutHeaders/,
/kBuffer/,
/kCapture/,
/kHighWaterMark/,
/\[Object: null prototype\]/,
/axios\/\d+\.\d+/,
// Suppress internal Node.js/axios object properties
/_allowHalfOpen:/,
/_maxListeners:/,
/_eventsCount:/,
/_sockname:/,
/_pendingData:/,
/_pendingEncoding:/,
/_httpMessage:/,
/_currentUrl:/,
/autoSelectFamilyAttemptedAddresses:/,
/errored.*null/,
/writableFinished:/,
/writableEnded:/,
/readable.*:/,
// Suppress common object dump fragments
/^\s*server:\s*null,?\s*$/,
/^\s*parser:\s*null,?\s*$/,
/^\s*timeout:\s*\d+,?\s*$/,
/^\s*\},?\s*$/,
/^\s*\],?\s*$/,
/^\s*\[\s*$/,
/^\s*\{\s*$/,
];
// =============================================================================
@ -674,13 +706,31 @@ export class PostStartupMonitor {
return true;
}
// Suppress lines that look like object dump fragments
// (indented lines with property names ending in colon or brackets)
const trimmed = output.trim();
if (/^\s*[\w_]+:\s*[\[\{]/.test(trimmed) && trimmed.length < 60) {
// Suppress lines that look like object dump fragments
// Property assignments: "propName: value," or "propName: {"
if (/^[\w_]+:\s*[\[\{\w'"]/.test(trimmed) && trimmed.length < 80) {
return true;
}
if (/^\s*[\}\]],?\s*$/.test(trimmed)) {
// Closing brackets/braces
if (/^[\}\]],?\s*$/.test(trimmed)) {
return true;
}
// Array items that are just strings
if (/^'[^']*',?\s*$/.test(trimmed)) {
return true;
}
// Lines that are mostly whitespace with brackets
if (/^\s*[\[\{\}\]]\s*$/.test(trimmed)) {
return true;
}
// Stack trace internals (node:net, node:internal)
if (/at\s+\w+\s+\(node:/.test(trimmed)) {
return true;
}
// errno/syscall/address lines from connection errors (keep the main ECONNREFUSED line)
if (/^\s*(errno|syscall|address|port):\s*/.test(trimmed)) {
return true;
}

View file

@ -442,10 +442,13 @@ export class ServiceManager {
this.logger.setSilent(true);
}
// Reset startup state
this.startupComplete = false;
// Preserve postStartupMonitor if already set (restart case)
// Caller will re-assign after start() completes if needed
// Reset startup state only for fresh starts, not restarts
// If postStartupMonitor is already set, this is a restart - preserve state
// so output continues routing to the monitor (which suppresses during restart)
const isRestart = this.postStartupMonitor !== undefined;
if (!isRestart) {
this.startupComplete = false;
}
this.startTime = Date.now();