Repository navigation
fix(mock): create HTTP server after app is ready - #6071
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughBoth mock application implementations now install an error handler when needed and wait for application readiness before creating the HTTP server. Tests cover requests after readiness and startup error handling. ChangesMock application startup
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The mock server is created after the application is ready, and startup errors retain their expected handling. No identified issue blocks merging after normal checks. 🚥 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 |
Deploying egg-v3 with
|
| Latest commit: |
5da22b5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://bddc1695.egg-v3.pages.dev |
| Branch Preview URL: | https://codex-fix-mock-http-ready.egg-v3.pages.dev |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Both startup paths use the corrected ordering, with focused regression coverage and no identified blocking issues.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes premature HTTP handler creation in @eggjs/mock, preventing incomplete middleware chains from returning unexpected 404 responses.
Changes:
- Creates HTTP servers after application readiness in normal and parallel startup.
- Preserves post-readiness
serverevents and adds regression coverage.
| File | Description |
|---|---|
plugins/mock/test/fixtures/snapshot-framework/index.js |
Models middleware composition that captures the current list. |
plugins/mock/test/fixtures/parallel-framework/index.js |
Makes responses reflect readiness at handler creation. |
plugins/mock/test/app.test.ts |
Tests middleware composition and parallel server readiness. |
plugins/mock/src/lib/parallel/app.ts |
Defers parallel server creation until ready. |
plugins/mock/src/lib/mock_http_server.ts |
Clarifies server-event ownership in comments only. |
plugins/mock/src/lib/app.ts |
Defers normal server creation until ready. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6071 +/- ##
==========================================
+ Coverage 83.61% 84.02% +0.41%
==========================================
Files 731 731
Lines 22608 22612 +4
Branches 4554 4556 +2
==========================================
+ Hits 18903 19000 +97
+ Misses 3202 3121 -81
+ Partials 503 491 -12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Deploying egg with
|
| Latest commit: |
5da22b5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://237c3929.egg-cci.pages.dev |
| Branch Preview URL: | https://codex-fix-mock-http-ready.egg-cci.pages.dev |
@eggjs/mockcreates the HTTP handler before asynchronous middleware loading finishes. When middleware composition copies the list, requests use an incomplete chain and return404.Create the server after
app.ready()in both normal and parallel startup. The handler then includes all loaded middleware, and theserverevent still runs after readiness. Register the defaulterrorlistener before startup so application errors remain handled.Summary by CodeRabbit