Skip to content

fix(devtools): run defineViteDevToolsPlugin only for client vite#977

Open
huang-julien wants to merge 1 commit intomainfrom
fix/rpc
Open

fix(devtools): run defineViteDevToolsPlugin only for client vite#977
huang-julien wants to merge 1 commit intomainfrom
fix/rpc

Conversation

@huang-julien
Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

Found bug when testing out nuxt/hints#318 with Vite 8 + devtools 4.0.0-alpha.3

We need to run connectDevToolsKit only once otherwiser the RPC instance is overriden and won't work.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e66b954c-d9c1-47a8-bb1e-58f56027a93d

📥 Commits

Reviewing files that changed from the base of the PR and between 4c594ce and 61ee97a.

📒 Files selected for processing (2)
  • packages/devtools/src/module-main.ts
  • packages/devtools/src/server-rpc/index.ts

📝 Walkthrough

Walkthrough

This change modifies the Vite DevTools plugin initialization to prevent server-side execution. The first file adds a { server: false } configuration option to defineViteDevToolsPlugin, disabling server-side plugin execution. The second file adds a guard condition to connectDevToolsKit that returns early if the DevTools Kit context is already established, preventing subsequent connections from overwriting the initial RPC context. Together, these changes ensure the plugin runs only on the client side and maintains a single, consistent DevTools Kit connection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: restricting the Vite DevTools plugin to run only for client-side Vite instances, which directly addresses the bug described in the PR objectives.
Description check ✅ Passed The description is related to the changeset, explaining the bug context (Vite 8 + devtools testing) and the core issue (connectDevToolsKit being called multiple times overrides RPC instance), which aligns with the code changes made.

✏️ 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/rpc

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.

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