-
Notifications
You must be signed in to change notification settings - Fork 1
Fix failover validator coroutine leak when event loop is active #700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
WalkthroughThe changes modify backend validation in the failover route validator to delay coroutine creation until the event loop state is confirmed. When the loop is running, the method returns early with a warning; otherwise, it constructs and executes the coroutine. New tests validate both scenarios and ensure no coroutine leakage. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Validator
participant EventLoop
participant Coroutine as Coroutine<br/>(delayed)
participant Backend
rect rgba(240, 248, 255, 0.3)
Note over Validator: Old Flow (creates eagerly)
Caller->>Validator: validate()
Validator->>Coroutine: create (always)
Validator->>EventLoop: check running
alt Loop active
Validator-->>Caller: return with warning
Coroutine--xCaller: (leaked, unawaited)
else Loop inactive
Validator->>Coroutine: await via asyncio.run()
Coroutine->>Backend: validate_backend_and_model()
Backend-->>Coroutine: result
Validator-->>Caller: return result
end
end
rect rgba(220, 240, 220, 0.3)
Note over Validator: New Flow (creates conditionally)
Caller->>Validator: validate()
Validator->>EventLoop: check running
alt Loop active
Validator-->>Caller: return warning (no coroutine)
else Loop inactive
Validator->>Coroutine: create
Validator->>Coroutine: await via asyncio.run()
Coroutine->>Backend: validate_backend_and_model()
Backend-->>Coroutine: result
Validator-->>Caller: return result
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (2)**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (2)src/core/persistence.py (2)
tests/unit/core/test_persistence_failover_validator.py (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (4)
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. Comment |
Summary
Testing
vulture,bandit, and fixtures required by snapshot-based tests)Codex Task
Summary by CodeRabbit
Bug Fixes
Tests