Skip to content

Fix Vite dev-server integration bugs#1746

Merged
cossssmin merged 3 commits into
masterfrom
fix/vite-integration-bugs
Jun 9, 2026
Merged

Fix Vite dev-server integration bugs#1746
cossssmin merged 3 commits into
masterfrom
fix/vite-integration-bugs

Conversation

@cossssmin

@cossssmin cossssmin commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Fixed file watching to work correctly when project root is a subdirectory.
    • Improved renderer lifecycle management during server shutdown and configuration changes.
    • Enhanced async handling of server close operations.
  • Documentation

    • Clarified Vite configuration behavior—the dev server does not load project vite.config files.
  • Tests

    • Added comprehensive dev server test suite covering configuration changes and file watching behavior.

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR enhances the Maizzle dev server by fixing server lifecycle management, improving configuration change handling with proper renderer state synchronization, clarifying configuration documentation, and adding comprehensive test coverage for dev server behaviors including shutdown and hot module reload events.

Changes

Dev Server Enhancements

Layer / File(s) Summary
Server shutdown and lifecycle handling
src/plugin.ts
The httpServer close handler is now async and properly awaits maizzleServer.close() before nulling the reference, ensuring clean shutdown.
Configuration change and renderer state management
src/serve.ts
File watcher path matching now uses process.cwd() to handle subdirectory roots correctly, and the renderer is re-registered via setActiveRenderer() after config-triggered recreation to keep render calls using the fresh instance.
Configuration documentation updates
src/serve.ts, src/types/config.ts
ServeOptions.silent documentation clarifies it suppresses the startup banner; MaizzleConfig.vite documentation now reflects that the internal Vite SSR server never loads a project vite.config file and user options merge beneath Maizzle's required settings.
Serve dev server test coverage
src/tests/serve.test.ts
New comprehensive Vitest suite validates dev server lifecycle (renderer cleanup on close), config change handling including root-subdirectory cases, and HMR WebSocket event emission by manually driving watcher change events in a temporary filesystem.
Build and coverage configuration
.gitignore, vitest.config.ts
.gitignore adds .vite directory; Vitest coverage configuration excludes src/serve.ts and src/server/** from core library coverage.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix Vite dev-server integration bugs' directly and accurately describes the main purpose of the changeset, which addresses multiple bugs in the Vite dev-server integration including proper async handling in close handlers, file-watching path resolution, and renderer lifecycle management.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/vite-integration-bugs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
vitest.config.ts (1)

9-19: ⚡ Quick win

Clarify the coverage exclusion rationale.

The comment states these surfaces are "exercised by the running dev server, not unit tests," but the review stack context indicates this PR adds "comprehensive Vitest suite validates dev server lifecycle" in serve.test.ts. Consider revising the comment to acknowledge that while tests exist, coverage is excluded to keep metrics focused on the core library, or to reflect that integration-heavy code is better validated through running the dev server than coverage metrics.

🤖 Prompt for 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.

In `@vitest.config.ts` around lines 9 - 19, Update the explanatory comment above
the coverage.exclude entries in vitest.config.ts (the coverage: { exclude: [...]
} block) to acknowledge that while there are tests (e.g., the comprehensive
Vitest suite like serve.test.ts) that exercise dev-server lifecycle, these paths
('src/serve.ts' and 'src/server/**') are intentionally excluded so coverage
metrics remain focused on the core library and because integration-heavy server
lifecycle code is validated by running the dev server rather than line-level
coverage; revise the comment to clearly state that rationale.
🤖 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.

Nitpick comments:
In `@vitest.config.ts`:
- Around line 9-19: Update the explanatory comment above the coverage.exclude
entries in vitest.config.ts (the coverage: { exclude: [...] } block) to
acknowledge that while there are tests (e.g., the comprehensive Vitest suite
like serve.test.ts) that exercise dev-server lifecycle, these paths
('src/serve.ts' and 'src/server/**') are intentionally excluded so coverage
metrics remain focused on the core library and because integration-heavy server
lifecycle code is validated by running the dev server rather than line-level
coverage; revise the comment to clearly state that rationale.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a1bd6d62-c4ad-46cf-bc88-d88a72341857

📥 Commits

Reviewing files that changed from the base of the PR and between 7be7f41 and e8e8b4d.

📒 Files selected for processing (6)
  • .gitignore
  • src/plugin.ts
  • src/serve.ts
  • src/tests/serve.test.ts
  • src/types/config.ts
  • vitest.config.ts

@cossssmin cossssmin merged commit b016f6f into master Jun 9, 2026
6 checks passed
@cossssmin cossssmin deleted the fix/vite-integration-bugs branch June 10, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant