Skip to content
Source
Sign inSign up
TanStack/devtools

fix(devtools-bundler-core): do not pipe Vite-forwarded browser logs back to the browser #540

MergedAlemTuzlakmerged 2 commits intomain fromrefs/pull/540/headmerged by AlemTuzlak View on GitHub

Showing 3 changed files with 69 additions and 0 deletions.

x
0 of 3 viewed, 3 left
6 additions and 0 deletions.changeset/console-pipe-vite-forward-loop.mdAdded
View file
@@ -0,0 +1,6 @@
+---
+'@tanstack/devtools-bundler-core': patch
+'@tanstack/devtools-vite': patch
+---
+​
+Stop the console pipe feedback loop with Vite 8 `server.forwardConsole`. The server side of the pipe no longer sends browser logs that Vite printed in the terminal back to the browser.
54 additions and 0 deletionspackages/devtools-bundler-core/src/virtual-console.test.tsModified
View file
@@ -7,8 +7,30 @@
vi.useRealTimers()
vi.unstubAllGlobals()
delete (window as any).__TSD_CONSOLE_PIPE_INITIALIZED__
+ delete (globalThis as any).__TSD_SERVER_CONSOLE_PIPE_INITIALIZED__
})
​
+function setupServerErrorConsolePipe() {
+ const originalError = console.error
+ const originalErrorMock = vi.fn()
+ const fetchMock = vi.fn().mockResolvedValue(undefined)
+​
+ console.error = originalErrorMock
+ vi.stubGlobal('fetch', fetchMock)
+​
+ // Shadow `window` so the generated code takes its server branch.
+ const code = generateConsolePipeCode(['error'], TEST_VITE_URL)
+ new Function('window', code)(undefined)
+​
+ return {
+ fetchMock,