fix: resolve sidecar memory leak and session list API timeout#650
Open
ricwyc-max wants to merge 1 commit into
Open
fix: resolve sidecar memory leak and session list API timeout#650ricwyc-max wants to merge 1 commit into
ricwyc-max wants to merge 1 commit into
Conversation
Root cause: listSessions() performed full JSONL parsing for every session file on each API call, blocking the Bun event loop and causing WebSocket heartbeat timeouts, HTTP request queuing, and connection pileup. Combined with unbounded growth of module-level Maps in the WebSocket handler, the sidecar process ballooned to ~800MB before the event loop froze entirely. Changes: - Add 30s TTL in-memory cache for session metadata in listSessions(), with invalidation on all write paths (create/delete/rename/append/clear) - Add periodic cleanup (60s interval) for stale WebSocket handler Maps with a hard cap of 500 entries - Add 24h TTL for deletedSessions Set to prevent unbounded growth - Add sidecar health check thread in Rust: TCP probe every 60s, auto-restart after 5 consecutive failures (5 min of unresponsiveness) - Replace child.kill() with process tree kill (taskkill /T on Windows) to prevent orphaned CLI subprocesses when sidecar is terminated Fixes: session list loading timeout, sidecar memory leak, zombie processes Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
PR quality triageChanged areas: area:desktop, area:server CLI core policy: No CLI-core policy block detected. Missing-test policy: Blocked by policy until a maintainer applies Coverage baseline policy: No coverage-baseline policy block detected. CLI core files:
Coverage policy files:
Expected checks:
Test coverage signals:
Risk notes:
Hard merge gates still come from GitHub Actions, not AI review. Dosu handoff: Dosu can be used as the AI reviewer for risk explanation, missing-test prompts, and maintainer Q&A. If it does not comment automatically from the PR template, ask: @dosubot review this PR for changed-area risk, missing tests, docs impact, desktop startup risk, and CLI core impact. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: resolve sidecar memory leak and session list API timeout
Summary
listSessions()metadata with invalidation on all write paths. Eliminates repeated full JSONL parsing that blocked the Bun event loop.deletedSessionsSet inConversationService.child.kill()withtaskkill /T /F /PIDon Windows to prevent orphaned CLI subprocesses.Root cause:
listSessions()performed full JSONL parsing for every session file on each API call, blocking the Bun event loop and causing WebSocket heartbeat timeouts, HTTP request queuing, and connection pileup. Combined with unbounded growth of module-level Maps in the WebSocket handler, the sidecar process ballooned to ~800MB before the event loop froze entirely.Feature Quality Contract
Verification
bun run verifyfor code changes, including the coverage gate. — Blocked: no local Bun environment configuredRisk
allow-cli-core-change.allow-missing-tests. — Needs maintainer approval: runtime behavior not unit-testableallow-coverage-baseline-change.Test Plan
claude-sidecar.exeprocesses remain🤖 Generated with Claude Code