Skip to content

fix(devtools-vite): prevent console pipe loop and solid-js duplication#412

Open
rbrito02 wants to merge 3 commits intoTanStack:mainfrom
rbrito02:fix/vite8-console-pipe-looping
Open

fix(devtools-vite): prevent console pipe loop and solid-js duplication#412
rbrito02 wants to merge 3 commits intoTanStack:mainfrom
rbrito02:fix/vite8-console-pipe-looping

Conversation

@rbrito02
Copy link
Copy Markdown

@rbrito02 rbrito02 commented Apr 2, 2026

🎯 Changes

Two fixes for Vite 8 compatibility in @tanstack/devtools-vite referenced in #411 :

  • Uncomment resolve.dedupe for solid-js dependencies during serve mode, Vite 8's Rolldown bundler resolves solid-js as duplicate instances, causing "multiple instances" warnings to fire.
  • Save original console methods before piping wraps them and use those in onConsolePipe. In SSR frameworks (e.g. TanStack Start) where the SSR server shares the Vite dev server process, the injected piping code wraps console globally. When onConsolePipe calls console[level]() it hits the wrapped version instead of the original, causing piped messages to be re-piped.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes
    • Fixed a console pipe feedback loop that could cause repeated logging.
    • Resolved Solid.js duplication issues when using Vite 8.

@rbrito02 rbrito02 changed the title Fix/vite8 console pipe looping fix(devtools-vite): prevent console pipe loop and solid-js duplication Apr 2, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d5fb1226-fba6-4e36-a1cb-d23c928e3ad7

📥 Commits

Reviewing files that changed from the base of the PR and between 764d4de and cf40ac8.

📒 Files selected for processing (1)
  • packages/devtools-vite/src/plugin.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/devtools-vite/src/plugin.ts

📝 Walkthrough

Walkthrough

Enabled Solid.js dependency dedupe in the Vite pre-config and changed console piping to call pre-bound original console methods (avoiding live indexing), plus a changeset added to publish a patch for @tanstack/devtools-vite fixing those issues.

Changes

Cohort / File(s) Summary
Release Documentation
\.changeset/twenty-impalas-poke.md
Added a changeset entry for a patch release targeting @tanstack/devtools-vite, describing fixes for a console pipe feedback loop and Solid.js duplication with Vite 8.
Plugin Configuration & Console Piping
packages/devtools-vite/src/plugin.ts
Uncommented/enabled Solid.js dedupe/optimizeDeps entries (resolve.dedupe, optimizeDeps.include) in Vite pre-config. In the custom-server console piping middleware, capture and use bound references from the original console (precomputed map) when piping client logs instead of indexing console[entry.level] at call time.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I hopped through code with nimble feet,
Bound the logs so echoes meet no repeat,
Solid's threads now join as one,
Vite hums softly — the fix is done,
Tiny changes, big delight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the two main fixes: preventing console pipe loops and solid-js duplication for Vite 8 compatibility.
Description check ✅ Passed The description is comprehensive, covering both fixes with clear motivation, and all required checklist items are completed including testing and changeset generation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/devtools-vite/src/plugin.ts (1)

255-261: Consider adding a fallback for defensive coding.

The client-side SSE handler in virtual-console.ts (line 184) uses a fallback pattern: originalConsole[entry.level] || originalConsole.log. The server-side handler here doesn't have this fallback.

While entry.level should always be a valid key in originalConsole (both use the same configured levels), adding a fallback would prevent a potential TypeError if an unexpected level is received.

🛡️ Proposed defensive fix
                   for (const entry of entries) {
                     const prefix = chalk.cyan('[Client]')
                     const logMethod =
-                      originalConsole[entry.level as ConsoleLevel]
+                      originalConsole[entry.level as ConsoleLevel] ||
+                      originalConsole.log
                     const cleanedArgs = stripEnhancedLogPrefix(
                       entry.args,
                       (loc) => chalk.gray(loc),
                     )
                     logMethod(prefix, ...cleanedArgs)
                   }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/devtools-vite/src/plugin.ts` around lines 255 - 261, The server-side
log dispatch currently assumes originalConsole[entry.level as ConsoleLevel]
exists and calls it directly; add a defensive fallback so that logMethod =
originalConsole[entry.level as ConsoleLevel] || originalConsole.log before
calling it, ensuring non-existent/invalid entry.level values won't throw a
TypeError; update the call site that uses logMethod(prefix, ...cleanedArgs)
(near usage of stripEnhancedLogPrefix, prefix, cleanedArgs) so it safely uses
the fallback.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/devtools-vite/src/plugin.ts`:
- Around line 255-261: The server-side log dispatch currently assumes
originalConsole[entry.level as ConsoleLevel] exists and calls it directly; add a
defensive fallback so that logMethod = originalConsole[entry.level as
ConsoleLevel] || originalConsole.log before calling it, ensuring
non-existent/invalid entry.level values won't throw a TypeError; update the call
site that uses logMethod(prefix, ...cleanedArgs) (near usage of
stripEnhancedLogPrefix, prefix, cleanedArgs) so it safely uses the fallback.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bcb8d738-7cb8-4051-8861-594dd635bb90

📥 Commits

Reviewing files that changed from the base of the PR and between 22d60fc and 764d4de.

📒 Files selected for processing (2)
  • .changeset/twenty-impalas-poke.md
  • packages/devtools-vite/src/plugin.ts

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