Claude/fix server client leak zxa5d#71
Merged
MarcosBrendonDePaula merged 6 commits intomainfrom Mar 1, 2026
Merged
Conversation
Server live components (e.g., LiveCounter, LiveChat) are imported by client components to get type inference and static metadata (componentName, defaultState, publicActions). However, these imports pulled in the full server class and all its transitive dependencies, including Node.js-only modules like 'fs', 'path', and server framework internals (RoomEventBus, LiveRoomManager, etc.), causing client build failures. Changes: - Add Vite plugin (fluxstack-live-strip) that intercepts @server/live/* imports from client code and replaces them with lightweight stubs containing only static metadata - Add LiveFileReader test component that imports 'fs' to demonstrate the leak scenario - Add 35 unit tests covering leak detection and plugin functionality https://claude.ai/code/session_018Hw3WNhmfUsuPFjwkL2BJ9
The plugin now watches server live component files during dev mode. When static metadata (defaultState, publicActions) changes, it triggers a client-side HMR update. Changes to server-only method bodies are silently ignored (no unnecessary client reloads). https://claude.ai/code/session_018Hw3WNhmfUsuPFjwkL2BJ9
Adds test cases for database (Prisma, Drizzle), Redis (ioredis), Node.js builtins (crypto, child_process, net, os), third-party libs (axios, sharp, nodemailer, AWS SDK), FluxStack server internals, and Bun-specific imports. All are fully stripped from client stubs. https://claude.ai/code/session_018Hw3WNhmfUsuPFjwkL2BJ9
- Delete LiveFileReader.ts — artificial demo component with path traversal vulnerability (unsanitized user input to readFileSync) - Rewrite vite-plugin-live-strip tests to cover real components (LiveCounter, LiveChat, LiveTodoList) instead of hypothetical libs (Prisma, Redis, AWS SDK, etc.) that don't exist in the project - Slim down server-client-leak tests from 365 to 75 lines, keeping only the assertions that document the actual problem and verify the fix is wired up 532 tests passing, 0 failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- live-components-specialist: WebSocket-based Live Components - fluxstack-core-researcher: read-only core framework analysis 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fluxstack-live-strip): Client components import server LiveComponent classes for typeinference (
Live.use(LiveCounter)), but those classes transitively pull infs,path,RoomEventBus,LiveRoomManager, and other Node.js/server-only modules — breaking the client build. The new plugin intercepts@server/live/*imports from client code and replaces them with lightweight stubs containing onlycomponentName,defaultState, andpublicActions.vite-plugins.tsfacade: Centralizes all framework-level Vite plugins (live-strip,tsconfig-paths,checker) into a singlefluxstackVitePlugins()call, cleaning upvite.config.ts.LiveTodoListserver component +TodoListDemoclient component as a collaborativereal-time todo list example using Room Events.
live-components-specialistandfluxstack-core-researcherClaude Code agents.What was wrong
Every client live component (
CounterDemo,ChatDemo,RoomChatDemo, etc.) doesimport { LiveCounter } from '@server/live/LiveCounter'. TheLiveComponentbase class incore/types/types.tshas runtime imports ofRoomEventBus,LiveRoomManager,LiveLogger, andServerWebSocketfrom Bun — all server-only. Withoutintervention, Vite tries to bundle all of these into the client, causing build failures.
How it works
resolveId— when a client file imports@server/live/Foo, it parses the server.tsfile with regex, extracts the 3 static fields, and writes a minimal.jsstub toapp/client/.live-stubs/.reload).
buildEnd.