fix(devtools-vite): inject the bus port into pre-bundled dependency chunks - #538
AlemTuzlak wants to merge 1 commit into
Conversation
…hunks Vite pre-bundles npm installs of @tanstack/react-devtools into chunks under node_modules/.vite/deps. Their ids do not contain "@tanstack/devtools", so connection-injection skipped them and __TANSTACK_DEVTOOLS_PORT__ stayed in the code. The browser then always dialed 4206, also when the server bus moved to another port. The examples link packages with workspace:*, and Vite does not pre-bundle linked packages, so the examples did not show the bug. Fixes #536
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: TanStack/devtools/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe connection-injection transform now processes Vite pre-bundled dependency chunks when they contain a connection placeholder. A test checks port replacement, and a patch changeset records the update. ChangesVite Connection Injection
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Matching Vite pre-bundled chunks receive the event-bus connection settings, with the client’s existing defaults preserved. No actionable merge-blocking risk remains. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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 |
|
View your CI Pipeline Execution ↗ for commit a2b0718
☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit a2b0718
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/angular-devtools
@tanstack/devtools
@tanstack/devtools-a11y
@tanstack/devtools-bundler-core
@tanstack/devtools-client
@tanstack/devtools-rspack
@tanstack/devtools-ui
@tanstack/devtools-utils
@tanstack/devtools-vite
@tanstack/devtools-webmcp
@tanstack/devtools-event-bus
@tanstack/devtools-event-client
@tanstack/preact-devtools
@tanstack/react-devtools
@tanstack/solid-devtools
@tanstack/svelte-devtools
@tanstack/vue-devtools
commit: |
When Vite pre-bundles
@tanstack/react-devtoolsfrom npm, the browser event bus client always connects to port 4206. The server bus can use another port (eventBusConfig.port, or a random port afterEADDRINUSE), so the client cannot connect. This PR also injects the port, host, and protocol into Vite's pre-bundled chunks undernode_modules/.vite/deps*.🎯 Changes
connection-injectionskipped pre-bundled chunks: their ids (for example/node_modules/.vite/deps/BRS44MK7-KeTQTbh5.js) do not contain@tanstack/devtools. As a result,__TANSTACK_DEVTOOLS_PORT__stayed in the code andgetDefaultPortreturned 4206./.vite/deps. The placeholder check still limits the transform to modules that contain the placeholders. Other packages stay untouched.workspace:*, and Vite does not pre-bundle linked packages.✅ Checklist
pnpm test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Testing
Commands run
vitest runinpackages/devtools-vite: 22 tests pass, with a new test for a.vite/depsid.eslintandtscinpackages/devtools-vite: pass.pnpm test:pr.Manual test
@tanstack/react-devtoolsfrom npm, and setdevtools({ eventBusConfig: { port: 4260 } }).WebSocket connection error, and the served.vite/depschunk still contains__TANSTACK_DEVTOOLS_PORT__.New WebSocket client connected, and the chunk contains4260.How this PR makes testing easy
A unit test in
packages/devtools-vite/tests/index.test.tstransforms a.vite/depsid and expects the port.Linked issues
Fixes #536
Risk / rollback
Low. Only modules that contain the devtools placeholders change. To undo, revert this PR.
🤖 Generated with Claude Code
Summary by CodeRabbit