Repository navigation
Keep the Vite plugin context methods when the client environment generates the public env manifest - #199
Conversation
…rates the public env manifest
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe client-serving load hook now delegates ChangesClient context handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change preserves watch-file handling for prototype-based contexts while retaining client manifest generation. No concrete merge-blocking risk remains in the reviewed change. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
Thanks a lot @steelanterns ! |
Symptom
In
vite devwith the TanStack Start adapter (10.2.15), server rendering intermittently fails with:Cause
When the
clientenvironment is the one generatingvirtual:oidc-spa/tanstack-start-public-envduringserve,loadswaps the resolver with:Vite's
PluginContextexposesaddWatchFile(and its other methods) on the class prototype, so the spread only copies own properties andaddWatchFileis lost.scan()then throws on its firstdiscover()call.It is intermittent because
scanPromiseis usually created first by the server environment and reused. Any source change resets it (onSourceChange), and after the full reload it is a race: when the client environment loads the virtual module first (e.g. through a warmup request), the dev server breaks.Fix
Pass
scan()exactly what it needs (resolvefrom the server environment,addWatchFiledelegated to the real plugin context) instead of spreading the context.Test
The existing "uses the server resolver when loaded by the client" case passes a plain object whose
addWatchFileis an own property, so the spread kept it. The new case uses a class instance with the methods on the prototype, like Vite's context. It fails with the error above before the fix and passes after.npx tsx --test scripts/tests/tanstack-start-bootstrap-env.test.ts: 26/26. (These tests are not run by CI, which only checks format and build; both pass.)Also checked in a real TanStack Start app (Vite 8.1.3): requesting
/@id/__x00__virtual:oidc-spa/tanstack-start-public-envbefore any SSR reproduces the error on 10.2.15, and no longer does with this change, including after a source change.Only affects dev (
command === "serve"); builds are unaffected. Not needed onv11, which no longer swaps the resolver.Follow-up to #196.
Summary by CodeRabbit