fix: wait for active dev rebuilds and watcher cleanup on shutdown - #206
AmanVarshney01 wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Essentials Run ID: 📒 Files selected for processing (6)
Included review availability: 2 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour. Summary by CodeRabbit
WalkthroughThe development CLI now returns an awaitable, idempotent watcher shutdown operation. It blocks new watcher-triggered rebuilds after shutdown starts, waits for active rebuilds, and continues service cleanup after reporting watcher or service-stop failures. Startup rollback follows the same cleanup sequence. Tests cover watcher failures, shutdown races, lifecycle events, and cleanup ordering. Local-development documentation describes the behavior. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to Shutdown cleanup failures are contained before service teardown, so no merge-blocking risk was identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
commit: |
Wait for file watchers to close before reporting shutdown complete, and let a second signal force termination when graceful cleanup stalls. Cover the shutdown controller with regression tests. Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/0-framework/3-tooling/cli/src/dev/run-dev.ts`:
- Around line 303-314: Update the shutdown flow around
createDevShutdownController and the watch rebuild callback to track active
detached rebuild tasks, set a shutdown flag that prevents any pending or resumed
task from deploying, and await or cancel all tracked tasks before
attachment.stopServices completes and “[dev] stopped.” is logged.
- Around line 69-78: Update the cleanup handling in run-dev.ts around the
shutdown controller so cleanup is invoked via Promise.resolve().then(cleanup),
routing synchronous and asynchronous failures through the existing rejection
branch and ensuring done rejects. Add a regression test in
packages/0-framework/3-tooling/cli/src/dev/__tests__/run-dev.test.ts covering a
synchronously throwing cleanup and asserting shutdown.done rejects.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2a8a7fd0-0af2-4361-9f00-b66aa86d1911
📒 Files selected for processing (6)
docs/guides/running-locally.mdpackages/0-framework/3-tooling/cli/src/dev/__tests__/run-dev.test.tspackages/0-framework/3-tooling/cli/src/dev/__tests__/watch.test.tspackages/0-framework/3-tooling/cli/src/dev/run-dev.tspackages/0-framework/3-tooling/cli/src/dev/watch.tsskills/prisma-composer/SKILL.md
501ee24 to
821d3c6
Compare
Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com>
|
✅ Gizmo reviewed 6606459 — posted 0 inline comment(s) this pass. Open findings: none Change walkthroughOverviewThis change fixes the dev session's shutdown behavior: it stops scheduling rebuilds once shutdown begins, drains in-flight assembly/converge work and watcher cleanup before stopping services, and surfaces synchronous as well as asynchronous cleanup failures without abandoning the remaining teardown. How it fits the codebase
|
There was a problem hiding this comment.
New findings: 🟡 4 minor · trace
Findings outside the diff
- 🟡 Minor · consistency packages/0-framework/3-tooling/cli/src/operations/dev.ts — dev.ts's stop-error event doc no longer matches when stop-error fires
The PR adds a second emitter ofstop-error: execute-dev.ts:326-329 now emits it whenstartedWatch.stop()rejects (watcher close failure), not just for services. The event's contract comment in the unchanged dev.ts:29 still reads "One service refused to stop during stop()", so a host consuming the typed events is toldstop-erroronly ever means a service failure. Update the variant's doc to cover watcher-cleanup failures too.
Recommended fix: Rewrite the comment on thestop-errorvariant inpackages/0-framework/3-tooling/cli/src/operations/dev.tsto something like: "A service or the file watcher refused to stop cleanly during stop(); teardown continues andstoppedstill follows." - 🟡 Minor · consistency packages/0-framework/3-tooling/cli/src/operations/dev.ts — Doc comments still point to the deleted run-dev.ts for the signal-ownership pattern
execute-dev.ts:5 and dev.ts:5 and dev.ts:43 still direct readers torun-dev.tsfor the signal-handling pattern, but that file no longer exists (the PR description confirms signal ownership moved to the consolidated CLI engine). These are the canonical docs for the "host owns signals, never register handlers" invariant this PR's tests enforce; the dangling pointer sends readers to a 404. Not introduced by this PR, but it touches the same doc surface and its PR summary is about the run-dev.ts removal.
Recommended fix: Replace thesee run-dev.tspointers with a reference to wherever signal ownership now lives (the consolidated CLI engine module), or drop the parenthetical.
Signed-off-by: Aman Varshney <amanvarshney.work@gmail.com>
Summary
Port the shutdown fix onto the current DevSession lifecycle. This branch now includes current main and keeps the obsolete run-dev.ts implementation deleted.
Review fixes
Both existing review findings are addressed with focused regressions: synchronous/asynchronous service cleanup failures and shutdown during assembly/converge. No new signal listener, forced process-exit workaround, or dependency has been added.
Why the old release blocker no longer applies
The original draft planned to replace process-wide signal handling in run-dev.ts after an Alchemy/node-utils release. Current main has already removed that file and moved signal ownership into the consolidated CLI engine. This PR only fixes the remaining DevSession cleanup and rebuild races; it does not change or claim to fix the separate upstream signal-handler issue.
Verification