Title: Pre-bundled client ignores the event bus port from devtools-vite · Issue #536 · TanStack/devtools · GitHub
Open Graph Title: Pre-bundled client ignores the event bus port from devtools-vite · Issue #536 · TanStack/devtools
X Title: Pre-bundled client ignores the event bus port from devtools-vite · Issue #536 · TanStack/devtools
Description: TanStack Devtools version @tanstack/react-devtools 0.10.13, @tanstack/devtools-vite 0.8.5 Framework/Library version React 19.3.0, Vite 8.3.1 Describe the bug and the steps to reproduce it In the browser, the event bus client always uses ...
Open Graph Description: TanStack Devtools version @tanstack/react-devtools 0.10.13, @tanstack/devtools-vite 0.8.5 Framework/Library version React 19.3.0, Vite 8.3.1 Describe the bug and the steps to reproduce it In the br...
X Description: TanStack Devtools version @tanstack/react-devtools 0.10.13, @tanstack/devtools-vite 0.8.5 Framework/Library version React 19.3.0, Vite 8.3.1 Describe the bug and the steps to reproduce it In the br...
Opengraph URL: https://github.com/TanStack/devtools/issues/536
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Pre-bundled client ignores the event bus port from devtools-vite","articleBody":"### TanStack Devtools version\n\n@tanstack/react-devtools 0.10.13, @tanstack/devtools-vite 0.8.5\n\n### Framework/Library version\n\nReact 19.3.0, Vite 8.3.1\n\n### Describe the bug and the steps to reproduce it\n\nIn the browser, the event bus client always uses port 4206, even when `devtools-vite` runs the server bus on another port. So `eventBusConfig.port` in `devtools()` has no effect in the browser. The `EADDRINUSE` fallback fails the same way. When another dev server holds 4206, the plugin moves its own bus to a random port. The browser still dials 4206.\n\n**Cause**\n\nThe `@tanstack/devtools:connection-injection` transform replaces `__TANSTACK_DEVTOOLS_PORT__` only in modules whose id contains `@tanstack/devtools` or `@tanstack/event-bus`. Vite pre-bundles `@tanstack/react-devtools` and serves the bus client from a chunk such as `/node_modules/.vite/deps/BRS44MK7-KeTQTbh5.js`. That id matches neither filter, so the placeholder stays, and `getDefaultPort(4206)` returns 4206.\n\nThe examples in this repository link the packages with `workspace:*`, and Vite does not pre-bundle linked packages.\n\n**Reproduction**\n\n`package.json` dependencies:\n\n```json\n\"@tanstack/devtools-vite\": \"0.8.5\",\n\"@tanstack/react-devtools\": \"0.10.13\",\n\"@vitejs/plugin-react\": \"6.1.1\",\n\"react\": \"19.3.0\",\n\"react-dom\": \"19.3.0\",\n\"vite\": \"8.3.1\"\n```\n\n`vite.config.ts`:\n\n```ts\nimport { devtools } from '@tanstack/devtools-vite'\nimport react from '@vitejs/plugin-react'\nimport { defineConfig } from 'vite'\n\nexport default defineConfig({\n plugins: [devtools({ eventBusConfig: { port: 4260, debug: true } }), react()],\n})\n```\n\n`src/main.tsx`, loaded from a plain `index.html`:\n\n```tsx\nimport { TanStackDevtools } from '@tanstack/react-devtools'\nimport { createRoot } from 'react-dom/client'\n\ncreateRoot(document.getElementById('root')!).render(\n \u003cTanStackDevtools eventBusConfig={{ connectToServerBus: true, debug: true }} />,\n)\n```\n\n1. Run `vite --port 3160`. The server bus starts on the configured port:\n\n ```\n 🌴 [tanstack-devtools:server-bus] Listening on http://localhost:4260\n ```\n\n2. Open http://localhost:3160/. The client fails to connect, and the server bus logs no client:\n\n ```\n [Client] 🌴 [tanstack-devtools:client-bus] Connecting to WebSocket server\n [Client] 🌴 [tanstack-devtools:client-bus] WebSocket connection error\n ```\n\n3. Fetch the served chunk that contains the bus client, for example `curl -s 'http://localhost:3160/node_modules/.vite/deps/BRS44MK7-KeTQTbh5.js'`. The placeholder is still there:\n\n ```js\n function getDefaultPort(configPort) {\n \tif (typeof __TANSTACK_DEVTOOLS_PORT__ !== \"undefined\") return __TANSTACK_DEVTOOLS_PORT__;\n \treturn configPort;\n }\n ```\n\nAs a control, add `optimizeDeps: { exclude: ['@tanstack/react-devtools'] }`. The server bus then logs `New WebSocket client connected`, and the client logs `WebSocket connection opened`. This exclusion is not a usable workaround, because it breaks the `dayjs` default import (#423).\n\n**Expected behavior**\n\nThe browser client connects to the port the server bus listens on, including the `EADDRINUSE` fallback port.\n\n**Workaround**\n\nPass the same fixed port to both sides: `devtools({ eventBusConfig: { port } })` and `\u003cTanStackDevtools eventBusConfig={{ port }} />`. This fails again when that port is taken.\n\n**Possible fix**\n\nAlso match ids under `/node_modules/.vite/deps/` in `connection-injection`. The placeholder check already limits the transform to modules that contain the placeholders.\n\n**Environment:** macOS (Darwin 25.6.0), Bun 1.4.2, Node 26.10.0, Chrome.\n\n### Your Minimal, Reproducible Example - (Sandbox Highly Recommended)\n\nThe complete reproduction is inline above: four files and three steps.\n\n### Do you intend to try to help solve this bug with your own PR?\n\nYes, I think I know how to fix it and will discuss it in the comments of this issue\n\n### Terms & Code of Conduct\n\n- [x] I agree to follow this project's Code of Conduct\n- [x] I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.\n","author":{"url":"https://github.com/svyatov","@type":"Person","name":"svyatov"},"datePublished":"2026-09-30T21:13:43Z","url":"https://github.com/TanStack/devtools/issues/536"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cd6a9b33-3576-082c-291d-a04a8fee38b6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8582:1B5107:19E2CC6:2388860:6AF9AC4F |
| html-safe-nonce | fe1c39285c46504a5910fcc774e385cd56881f81645898b43bb4a8b7c99b35f2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTgyOjFCNTEwNzoxOUUyQ0M2OjIzODg4NjA6NkFGOUFDNEYiLCJ2aXNpdG9yX2lkIjoiNTcyNzA5MzYzOTc4ODIxMTI4MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 518fa46f030b755f9fd3ac01a5b842b46192504ad873aee5f0ef0e8035582b3d |
| hovercard-subject-tag | issue:5653117096 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/TanStack/devtools/536/issue_layout |
| twitter:image | https://opengraph.githubassets.com/484961038e7144e08ed37dd7b94dd05990b4be747875b8c7f7f25c0314dcb7b8/TanStack/devtools/issues/536 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/484961038e7144e08ed37dd7b94dd05990b4be747875b8c7f7f25c0314dcb7b8/TanStack/devtools/issues/536 |
| og:image:alt | TanStack Devtools version @tanstack/react-devtools 0.10.13, @tanstack/devtools-vite 0.8.5 Framework/Library version React 19.3.0, Vite 8.3.1 Describe the bug and the steps to reproduce it In the br... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | svyatov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7 |
| turbo-cache-control | no-preview |
| go-import | github.com/TanStack/devtools git https://github.com/TanStack/devtools.git |
| octolytics-dimension-user_id | 72518640 |
| octolytics-dimension-user_login | TanStack |
| octolytics-dimension-repository_id | 1026402761 |
| octolytics-dimension-repository_nwo | TanStack/devtools |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1026402761 |
| octolytics-dimension-repository_network_root_nwo | TanStack/devtools |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 072e34035c13c31543fba9f025cbbbda4210dae4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width