Skip to content

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

Open
rbrito02 wants to merge 5 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 5 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: 0b531d1e-8091-4429-b23a-5ae07266fb9c

📥 Commits

Reviewing files that changed from the base of the PR and between cf40ac8 and 64f305c.

📒 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

Captured and used pre-bound original console methods for client log piping to avoid live-indexing feedback loops; added a changeset to publish a patch for @tanstack/devtools-vite that references a fix for Solid.js duplication with Vite 8.

Changes

Cohort / File(s) Summary
Release Changeset
/.changeset/twenty-impalas-poke.md
Added a changeset entry for a patch release of @tanstack/devtools-vite, documenting fixes for a console pipe feedback loop and Solid.js duplication with Vite 8.
Console piping logic
packages/devtools-vite/src/plugin.ts
In the custom-server console piping handler, capture a map of bound original console methods (keyed by configured consolePipingLevels) and call originalConsole[entry.level] (with fallback to originalConsole.log) when piping client logs instead of indexing the live console at call time.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I nibbled at echoes, bound each call,
No loops left bouncing off the wall,
Solid's duplicates hinted in the night,
A changeset stamps the patch just right,
Hops and fixes — everything's tight.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly summarizes the two main fixes addressed in the PR: preventing console pipe loops and solid-js duplication issues for Vite 8 compatibility.
Description check ✅ Passed The description includes the required template sections with clear explanations of changes, completed checklist items, and a changeset reference, meeting template requirements.
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

@AlemTuzlak
Copy link
Copy Markdown
Collaborator

would you mind disabling the solid stuff, deduping caused app crashes before so i'm not confident in merging it

@rbrito02
Copy link
Copy Markdown
Author

rbrito02 commented Apr 7, 2026

@AlemTuzlak okay that makes more sense why it was commented out tho I think it may be needed in some scenarios. Will try and look into crashes or alternatives to fix multiple instances error.

@AlemTuzlak
Copy link
Copy Markdown
Collaborator

Completely fair, I just wanna merge this PR and you can freely investigate that on another one.

@rbrito02
Copy link
Copy Markdown
Author

rbrito02 commented Apr 7, 2026

sounds good 👍

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.

2 participants