Repository navigation
fix(server): keep the stdio process alive across stdin EOF and SIGHUP - #48
jack-arturo wants to merge 2 commits into
Conversation
Claude was reporting the WordPress server as exiting early with an empty stderr log. A ref'd keepalive stops Node from draining the event loop when stdin closes, and SIGHUP is logged instead of killing the process.
…ing the process A full stderr pipe made fs.writeSync throw inside the rejection handler, and a watchdog interval above 2^31-1 overflowed Node's timer to 1ms. Diagnostics now swallow write failures, and the interval is clamped to the timer maximum.
| * closed fd must not turn a diagnostic into a fatal exception. */ | ||
| export function writeDiagnostic(message: string) { | ||
| try { | ||
| fs.writeSync(2, message.endsWith("\n") ? message : `${message}\n`); |
There was a problem hiding this comment.
SUGGESTION: writeDiagnostic swallows all errors including programming errors
If message is not a string (e.g., null, object), message.endsWith throws TypeError which is silently caught. Consider String(message) for defense in depth.
| const shutdown = (code = 0) => { | ||
| if (shuttingDown) return; | ||
| shuttingDown = true; | ||
| clearInterval(keepalive); |
There was a problem hiding this comment.
SUGGESTION: shutdown function doesn't clear the watchdog interval
The watchdog timer (created at line 155) is unref'd so it won't block exit, but clearing it in shutdown would be cleaner and avoid a tiny resource leak before process.exit.
| () => {}, | ||
| () => false, | ||
| ); | ||
| expect((timer as NodeJS.Timeout & { _idleTimeout: number })._idleTimeout).toBe( |
There was a problem hiding this comment.
SUGGESTION: Test accesses internal Node.js _idleTimeout property
_idleTimeout is not part of the public API and may change across Node versions. Prefer testing behavior (e.g., timer doesn't fire immediately) over implementation details.
Code Review SummaryStatus: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (3 files)
Fix these issues in Kilo Cloud Reviewed by nemotron-3-ultra-550b-a55b:free · Input: 54K · Output: 9.9K · Cached: 342K |
|
@codex review |
|
Babysit stopped — |
Summary
Cursor, via jack-arturo.
Test plan
npx vitest run tests/lifecycle.test.ts(8 tests, including a subprocess that stays up afterstdin.end())npx tsc --noEmit