fix(start-plugin-core): use duck-type check for RunnableDevEnvironment to avoid dual-package hazard#6994
fix(start-plugin-core): use duck-type check for RunnableDevEnvironment to avoid dual-package hazard#6994sleitor wants to merge 2 commits intoTanStack:mainfrom
Conversation
…t to avoid dual-package hazard Replace isRunnableDevEnvironment (instanceof-based) with duck-type check 'runner' in serverEnv to avoid false negatives when vite is aliased via pnpm overrides (e.g. vite-plus), which creates a dual-package hazard where two different RunnableDevEnvironment class references exist in memory. The 'runner' property (public getter) is unique to RunnableDevEnvironment and not present on FetchableDevEnvironment or DevEnvironment. Fixes TanStack#6982
|
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 (2)
📝 WalkthroughWalkthroughAdded a changeset entry documenting a bug fix in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
|
View your CI Pipeline Execution ↗ for commit 96eb75d
☁️ Nx Cloud last updated this comment at |
Bundle Size Benchmarks
Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better. |
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Fixes #6982
When is aliased to another package via pnpm overrides (e.g.
vite: npm:@voidzero-dev/vite-plus-core@latest), two differentRunnableDevEnvironmentclass references exist in memory. TheisRunnableDevEnvironment()helper usesinstanceofwhich returnsfalse, causing SSR middleware to never be registered and all routes returning 404.Changes
Replace
isRunnableDevEnvironment(serverEnv)(instanceof-based) with a duck-type check'runner' in serverEnvinpackages/start-plugin-core/src/dev-server-plugin/plugin.ts.The
runnerproperty (a public getter) is unique toRunnableDevEnvironment—FetchableDevEnvironmentandDevEnvironmentdon't have it. The existing'dispatchFetch' in serverEnvguard is preserved to correctly handle Nitro'sFetchableDevEnvironment.RunnableDevEnvironmentis still imported as a type only (for the TypeScript cast onserverEnv.runner.import()), so no runtime instanceof check remains.Testing
Summary by CodeRabbit
Bug Fixes