fix(backend): align pytest async loop scope - #14267
Conversation
🔍 PR Overlap DetectionThis check compares your PR against all other open PRs targeting the same branch to detect potential merge conflicts early. 🟢 Low Risk — File Overlap OnlyThese PRs touch the same files but different sections (click to expand)
Summary: 0 conflict(s), 0 medium risk, 10 low risk (out of 10 PRs with file overlap) Auto-generated on push. Ignores: |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📜 Recent review details⏰ Context from checks skipped due to timeout. (16)
🧰 Additional context used📓 Path-based instructions (1)Format Python code with `poetry run format`📄 CodeRabbit inference engine (AGENTS.md) Files:
🔇 Additional comments (1)
WalkthroughThe backend pytest configuration now uses session-scoped test loops by default. A graphiti collection hook assigns function-scoped loops to unscoped async tests in that directory. ChangesPytest event loop configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change aligns backend async tests with session-scoped fixtures while preserving explicit loop scopes and the graphiti function-scope exception; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 61c8ff0. Configure here.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #14267 +/- ##
==========================================
- Coverage 80.31% 80.30% -0.01%
==========================================
Files 3333 3333
Lines 253614 253625 +11
Branches 23532 23537 +5
==========================================
- Hits 203698 203683 -15
- Misses 44636 44659 +23
- Partials 5280 5283 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|

Why / What / How
The full backend suite still reused process-global Prisma and async Redis pools across pytest event loops after #14259. The backend already ran session-scoped async fixtures, but unscoped async tests ran on function-scoped loops by default. Stack PR #14078 added enough async coverage to reproduce the mismatch consistently: later session-scoped Copilot tests saw Prisma and Redis connections created on loops that pytest had closed.
This aligns ordinary async backend tests with the existing session-scoped fixture loop. The Graphiti subtree keeps function-scoped loops for tests backed by its explicitly function-scoped FalkorDB fixtures and per-loop ingestion state. Tests that explicitly request another loop scope retain that behavior.
Changes 🏗️
asyncio_default_test_loop_scopetosessionin the backend pytest configuration.conftest.py.Checklist 📋
For code changes:
For configuration changes:
.env.defaultis already compatible with my changesdocker-compose.ymlis already compatible with my changes