GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||
GeezerVison is showing github.com — devtools-vite console pipe: infinite feedback loop with Vite 8 `server.forwardConsole` — one console entry floods browser + terminal · Issue #482 · TanStack/devtools Closed DescriptionWhich project does this relate to?Devtools Describe the bug
The cycle:
In a real TanStack Start app (Vite 8.0.16, devtools-vite 0.8.1) we measured one failed fetch turning into 37,779 browser console entries in 30s and a 2.5 GB terminal log in about a minute. The related fix in 0.6.1 ("console pipe feedback loop … with Vite 8") does not cover this path — 0.7.0 and 0.8.1 both reproduce. Your Example Website or AppSee minimal reproduction below (4 files) Steps to Reproduce the Bug or Issuepackage.json {
"name": "tsd-console-loop-repro",
"private": true,
"type": "module",
"scripts": { "dev": "vite" },
"devDependencies": {
"@tanstack/devtools-vite": "0.8.1",
"vite": "8.0.16"
}
}vite.config.js — bare Vite + devtools + a 10-line SSR middleware (the pipe's server console patch is only injected into SSR modules, so a plain SPA doesn't show it): import { devtools } from '@tanstack/devtools-vite' export default { appType: 'custom', plugins: [ devtools(), { name: 'mini-ssr', configureServer(server) { return () => { server.middlewares.use(async (req, res) => { const { render } = await server.ssrLoadModule('/entry-server.js') res.setHeader('content-type', 'text/html') res.end(await server.transformIndexHtml(req.url ?? '/', render())) }) } }, }, ], } entry-server.js — the export function render() { return '<html><body><h1>tsd console loop repro</h1><script type="module" src="/main.js"></script></body></html>' } main.js — the function createRoot(el) { el.textContent = 'mounted' } createRoot(document.querySelector('h1')) // A single console entry seeds the infinite echo. console.error('seed') Then:
Measured on this repro (Playwright counting console messages, no interaction after load):
…growing without bound; the dev-server terminal shows the same nested Expected behaviorOne Screenshots or VideosNo response Platform
Additional contextWe're currently carrying this as a // Skip our own TSD Console Pipe logs to avoid recursion/noise
if (args.length > 0 && typeof args[0] === 'string' &&
(args[0].indexOf('[TSD Console Pipe]') !== -1 ||
args[0].indexOf('[@tanstack/devtools') !== -1)) {
return;
}
+
+ // Vite 8's server.forwardConsole re-prints CLIENT console output in
+ // the terminal ("[vite] (client) [console.warn] ..."). Those are not
+ // server logs — re-broadcasting them to the browser makes the browser
+ // log them again, which vite forwards again: an infinite
+ // client->server->client echo. Skip vite-forwarded client logs.
+ if (isServer && args.length > 0 && typeof args[0] === 'string' &&
+ (args[0].indexOf('(client)') !== -1 ||
+ args[0].indexOf('[console.') !== -1)) {
+ return;
+ }With that guard in place: same app, same seed error — browser console stays at 5 entries (flat), terminal stays quiet, and genuine server logs still mirror into the browser once, as intended. A marker-based handshake between the pipe and Vite's forwarder would probably be more robust than string matching, but the diff above demonstrates the loop and the fix. Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |