Repository navigation
fix(server): drop the placeholder attachment when the pty cannot spawn - #155
Conversation
A synchronous Bun.spawn throw in spawnAttachment left a record without a pty in attachments. The next attach joined it and sat blank, and its close crashed the server in closeAttachment. A retried attach that threw the same way was uncaught. Fixes #154
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe attach path now handles synchronous helper startup failures during initial attachment and retry. It reports failures, cleans up attachment state, and includes contract tests for later attachments. ChangesAttach spawn failures
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The attachment failure handling is mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The failure paths now remove unusable attachments and report retry failures without adding a new entrypoint or expanding client privileges. Review is warranted because several clients can share the attachment and depend on its terminal signals. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Release v0.3.39: moves the Unreleased notes under 0.3.39 and bumps `package.json` and `herdr-plugin.toml`. In this release, all fixes: a password sent right after a reconnect (#244), typing and keys outliving their connection (#235), panning a terminal whose grid is not the browser's own on a phone (#241), omo's question form in the chat (#237 by @nahwan-kim), and a held pane resumed by a late herdr answer plus a new shell taken for OmO (#243). No remote bundle change: `REMOTE_BUNDLE_VERSION` stays 9. Changelog housekeeping that was waiting for a release: - Compare links at the bottom now cover 0.3.31 to 0.3.39 (they stopped at 0.3.30), and `[Unreleased]` compares from v0.3.39. - Five references that were a bare `#N` are full PR links with their author: #164 is the issue PR #199 fixed, #154 the issue PR #155 closed, and #45 and #6 are PRs. No other wording of released entries changed. `bun scripts/release-notes.ts 0.3.39` prints the notes and exits 0.
Change
Fixes #154.
spawnAttachmentputs a placeholder record (pty: undefined) inattachmentsand then callsstart(). Whennew PtySession()throws synchronously (Bun.spawnthrows for ENOENT, for example whennodeis missing from PATH, or for fd/process limits), the first client gotcommand_failed, but the placeholder stayed in the map:ensureAttachmentand got neither output nor an error.close → detach → closeAttachmentreadattachment.pty.exitedand threw a TypeError that ended the process. The supervisor exits with the bridge (Bridge exited unexpectedly (1)), so the server stayed down.The issue's other theory, a synchronous
onExitfrom the constructor, can't happen:onExitruns insidePromise.all(...).then.The fix:
start()in a try. A failed spawn deletes the placeholder, logs the failure and rethrows, so the attaching clients (and any joiners of the same pending creation) getcommand_failedin-band.start()inside thesetTimeout(the "read in progress" retry) threw uncaught. Now it reportscommand_failedpluspty-exitto the pane's clients and closes the attachment. The pty it closes is the one that already exited.There's no guard in
closeAttachment: a record without a pty can no longer exist, and a guard would only hide the cause. Restarting the bridge from the supervisor after a crash is a separate design question and isn't part of this PR.Validation
Two new tests in
server/output.contract.test.ts, both made to fail by breakingPATHwhile the sidecar spawns:command_failed. A second client then attaches for real, and closing it tears the attachment down cleanly. A third attach then works.command_failedpluspty-exit, and the pane attaches again afterwards.Both tests fail on
main. The first fails with the issue's exactTypeError ... at closeAttachment. The second fails with an uncaughtExecutable not found in $PATH: "node"from the retry timer. Both pass with the fix.bun run typecheck: passbun run test:unit: 441 passbun run test:integration: 125 pass