fix(devtools-vite): prevent console pipe loop and solid-js duplication#412
fix(devtools-vite): prevent console pipe loop and solid-js duplication#412rbrito02 wants to merge 3 commits intoTanStack:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughEnabled 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 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 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.levelshould always be a valid key inoriginalConsole(both use the same configured levels), adding a fallback would prevent a potentialTypeErrorif 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
📒 Files selected for processing (2)
.changeset/twenty-impalas-poke.mdpackages/devtools-vite/src/plugin.ts
🎯 Changes
Two fixes for Vite 8 compatibility in
@tanstack/devtools-vitereferenced in #411 :resolve.dedupefor solid-js dependencies during serve mode, Vite 8's Rolldown bundler resolves solid-js as duplicate instances, causing "multiple instances" warnings to fire.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. WhenonConsolePipecallsconsole[level]()it hits the wrapped version instead of the original, causing piped messages to be re-piped.✅ Checklist
pnpm test:pr.🚀 Release Impact
Summary by CodeRabbit