fix(host-service): clean up exited terminals on workspace delete#3856
Conversation
`disposeSessionsByWorkspaceId` filtered by `status = "active"`, so any session whose row had drifted to `exited` (e.g. via `pty.onExit`) was skipped on workspace deletion — leaving the in-memory `sessions` Map entry behind. Widen to `status != "disposed"` so zombie rows get disposed too. `disposeSession` is already idempotent against a dead PTY.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe terminal session disposal query was broadened to target all non-disposed sessions instead of only active ones. The Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
🚀 Preview Deployment🔗 Preview Links
Preview updates automatically with new commits |
Greptile SummaryThis PR fixes a memory leak in Confidence Score: 5/5Safe to merge — minimal, targeted fix with no regressions on other code paths. Single two-line change (import + filter predicate). The fix is logically correct: No files require special attention.
|
| Filename | Overview |
|---|---|
| packages/host-service/src/terminal/terminal.ts | Widened disposeSessionsByWorkspaceId filter from status = "active" to status != "disposed", fixing a memory leak where in-memory sessions in the exited state were skipped on workspace deletion. |
Reviews (1): Last reviewed commit: "fix(host-service): clean up exited termi..." | Re-trigger Greptile
Summary
disposeSessionsByWorkspaceIdfiltered DB rows bystatus = "active", so any session whose row had drifted toexited(viapty.onExit) was skipped on workspace deletionsessionsMap entry stayed behind in those cases — slow leak per workspace deletestatus != "disposed"so zombie rows are picked up too.disposeSessionis already idempotent against a dead PTY (see comment atterminal.ts:271)Terminals are intentionally persistent across most lifecycle events; this only changes behavior on the explicit workspace-delete path. Pane-deletion path is unaffected (it goes through
disposeSessiondirectly).Test plan
exited, then delete the workspace and confirm nosessionsMap entry remainsSummary by cubic
Clean up exited terminal sessions on workspace delete to prevent leftover in-memory
sessionsentries.disposeSessionsByWorkspaceIdnow disposes all rows wherestatus != 'disposed'(usingnefromdrizzle-orm) instead of onlyactive; pane deletion is unchanged.Written for commit 9ab7de4. Summary will update on new commits. Review in cubic
Summary by CodeRabbit