Skip to content

fix: prevent zombie client re-insertion after disconnectClient#88

Merged
EtanHey merged 1 commit into
mainfrom
fix/brainbar-zombie-client
Mar 18, 2026
Merged

fix: prevent zombie client re-insertion after disconnectClient#88
EtanHey merged 1 commit into
mainfrom
fix/brainbar-zombie-client

Conversation

@EtanHey
Copy link
Copy Markdown
Owner

@EtanHey EtanHey commented Mar 18, 2026

Summary

  • After sendResponse() calls disconnectClient(fd:) to drop a stalled client, readFromClient() would write the ClientState copy back into the clients dictionary, re-inserting a zombie entry with a cancelled DispatchSource
  • Now checks clients[fd] after each sendResponse() and bails if the client was removed
  • write() returning 0 now properly disconnects instead of silently breaking the write loop

Found by code review agent during PR #87 review.

Test plan

  • swift build -c release clean
  • Full MCP handshake works after deploy
  • Raw JSON fallback still works

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

After sendResponse() calls disconnectClient(fd:) to drop a stalled
client, readFromClient() would write the ClientState copy back into
the clients dictionary at line 178, re-inserting a zombie entry with
a cancelled DispatchSource. Now checks clients[fd] after each
sendResponse() and bails if the client was removed.

Also: write() returning 0 now properly disconnects instead of
silently breaking the write loop.

Found by code review agent on PR #87.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 18, 2026

Warning

Rate limit exceeded

@EtanHey has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 16 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: bbe479e4-64a7-4285-8d8c-58949084bb4b

📥 Commits

Reviewing files that changed from the base of the PR and between 9e6ac8b and 6becb2a.

📒 Files selected for processing (1)
  • brain-bar/Sources/BrainBar/BrainBarServer.swift
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/brainbar-zombie-client
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@EtanHey
Copy link
Copy Markdown
Owner Author

EtanHey commented Mar 18, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 18, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@EtanHey EtanHey merged commit 37b42d0 into main Mar 18, 2026
5 checks passed
@EtanHey EtanHey deleted the fix/brainbar-zombie-client branch March 18, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant