fix(core): resolve mount() promise when unmount() is called directly#778
fix(core): resolve mount() promise when unmount() is called directly#778Pranaykarvi wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughApp.unmount(exitCode = 0) now resolves any pending mount() resolver with the provided exit code and clears it; App.exit(code) forwards the code to unmount(). A new test verifies that calling unmount() resolves an in-flight mount() promise. ChangesResolve pending mount promise on unmount
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Hey @Karanjot786, |
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/core/src/app/App.test.ts`:
- Around line 37-53: The test uses bare any and a blanket type assertion for
AppOptions; replace those with explicit, strict types (e.g., declare fakeStdout:
Partial<WritableStream> | Partial<Stream> or a Fixture type matching the App
constructor's expected stdout/stdin shapes, and fakeStdin similarly) and pass
the options as a properly typed object (or use Partial<AppOptions>) instead of
"as AppOptions"; if a type escape is truly unavoidable, add a short inline
comment on each use of any or as AppOptions explaining why it cannot be strictly
typed. Ensure you update the declarations for fakeStdout, fakeStdin and the App
instantiation (symbols: fakeStdout, fakeStdin, App, AppOptions) to remove bare
any/type assertion or justify them with comments.
In `@packages/core/src/app/App.ts`:
- Around line 234-237: unmount() currently always calls this._exitResolve(0)
which clobbers any code passed to exit(code); change the flow so the actual exit
code propagates: have exit(code) set a stored value (e.g. this._exitCode = code)
or pass the code into unmount(code), and then have unmount() resolve
this._exitResolve with that stored/passed code (or default to 0 only if none
provided). Update references to exit(code), unmount(), and this._exitResolve
accordingly so the exit code is preserved.
🪄 Autofix (Beta)
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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e75e6e67-1dc0-4292-a3b9-dbaca8e109f8
📒 Files selected for processing (2)
packages/core/src/app/App.test.tspackages/core/src/app/App.ts
|
@Karanjot786,
All 155 core tests pass. |
Summary
Closes #776
Problem
App.mount()returns a promise that only resolved whenexit()was called internally.Calling
unmount()directly left_exitResolvenever invoked, causing themount()promise to hang forever in tests and custom shutdown wrappers.
Fix
In
unmount(), after the existing teardown (events.removeAll()), added:exit()is completely untouched — it still callsunmount()internally soexisting behavior is preserved.
Files Changed
packages/core/src/app/App.ts— resolve_exitResolveinunmount()packages/core/src/app/App.test.ts— new test covering the hang scenarioTest Results
bun vitest run packages/core— 155 passedbun run typecheck— passedbun run build— all packages built successfullySummary by CodeRabbit