Add isolated aimux-dev runtime#9
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR adds an isolated dev runtime ( ChangesIsolated Development Runtime with Dynamic Daemon Configuration
Sequence DiagramsequenceDiagram
participant Client as Client Process
participant Env as AIMUX_DAEMON_HOST/AIMUX_DAEMON_PORT
participant Daemon as Daemon Process
Client->>Env: getDaemonHost()/getDaemonPort()
Env-->>Client: host & port
Client->>Daemon: GET /health (probe via getDaemonBaseUrl())
Daemon-->>Client: {pid, port}
Client->>Client: ensureDaemonRunning() adopts daemon & persists port
Client->>Daemon: requestDaemonJson() (dynamic URL)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/daemon.ts (1)
90-104:⚠️ Potential issue | 🟠 Major | ⚡ Quick winClose partially opened stdio descriptors on failure.
If Line 92 succeeds and Line 93 throws, the first fd is leaked because the catch path does not close already-opened descriptors.
🧹 Proposed fix
function loggingChildStdio(path: string): { stdio: StdioOptions; close: () => void } { const logging = getLoggingConfig(); if (!logging.enabled) return { stdio: "ignore", close: () => {} }; + let stdout: number | null = null; + let stderr: number | null = null; try { ensureParent(path); - const stdout = openSync(path, "a"); - const stderr = openSync(path, "a"); + stdout = openSync(path, "a"); + stderr = openSync(path, "a"); let closed = false; const close = () => { if (closed) return; closed = true; - closeSync(stdout); - closeSync(stderr); + if (stdout !== null) closeSync(stdout); + if (stderr !== null) closeSync(stderr); }; return { stdio: ["ignore", stdout, stderr], close }; } catch { + if (stdout !== null) closeSync(stdout); + if (stderr !== null) closeSync(stderr); return { stdio: "ignore", close: () => {} }; } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/daemon.ts` around lines 90 - 104, The code can leak an open file descriptor if ensureParent(path) or the second openSync(path, "a") throws; modify the stdio-opening logic (the block that calls ensureParent, openSync and defines close) to track each opened fd in local variables (e.g., stdoutFd, stderrFd), open them sequentially, and if any subsequent step throws ensure you close any previously opened fd(s) in the catch path before rethrowing or returning the fallback; also ensure the returned close() (the close variable) closes both stdoutFd and stderrFd using closeSync when present.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/daemon.ts`:
- Around line 32-35: getDaemonHost currently returns any AIMUX_DAEMON_HOST value
unvalidated, which lets callers (like the daemon bind logic) expose services to
non-loopback interfaces; update getDaemonHost to only accept loopback addresses
(127.0.0.1 or ::1) by default and fall back to DEFAULT_DAEMON_HOST for any other
value, and add an explicit opt-in environment flag (e.g.,
AIMUX_DAEMON_HOST_ALLOW_PUBLIC='1') to permit non-loopback values; implement
validation using Node's net.isIP or equivalent, reference getDaemonHost and any
direct reads of process.env.AIMUX_DAEMON_HOST to ensure they use the new
validated getter.
---
Outside diff comments:
In `@src/daemon.ts`:
- Around line 90-104: The code can leak an open file descriptor if
ensureParent(path) or the second openSync(path, "a") throws; modify the
stdio-opening logic (the block that calls ensureParent, openSync and defines
close) to track each opened fd in local variables (e.g., stdoutFd, stderrFd),
open them sequentially, and if any subsequent step throws ensure you close any
previously opened fd(s) in the catch path before rethrowing or returning the
fallback; also ensure the returned close() (the close variable) closes both
stdoutFd and stderrFd using closeSync when present.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: fadd99c4-535d-4c8d-8078-1bc48d22e96a
📒 Files selected for processing (12)
README.mdapp/eslint.config.mjsapp/package.jsonbin/aimux-devdocs/dev-runtime.mdpackage.jsonrelay/wrangler.tomlsrc/daemon.test.tssrc/daemon.tssrc/login-flow.tssrc/paths.test.tssrc/paths.ts
Summary
Verification
Summary by CodeRabbit
New Features
Documentation
Refactor