fix: failed to create multiple HMR connections#5844
Merged
chenjiahan merged 3 commits intomainfrom Aug 14, 2025
Merged
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a critical HMR (Hot Module Replacement) issue where multiple browser tabs could not maintain independent connections to the development server. Previously, new WebSocket connections would overwrite existing ones for the same token, breaking HMR for previously opened tabs.
- Replaced single WebSocket storage with a Set-based approach to handle multiple connections per token
- Updated all socket operations to iterate over connection sets instead of single connections
- Added comprehensive e2e test to verify multiple browser tabs can receive HMR updates simultaneously
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/server/socketServer.ts | Core fix: Changed socket storage from Map<string, Ws> to Map<string, Set> to support multiple connections per token |
| e2e/cases/hmr/multiple-connection/src/index.ts | Test entry point that creates a unique element to verify HMR preservation across tabs |
| e2e/cases/hmr/multiple-connection/src/App.tsx | Simple React component for HMR testing |
| e2e/cases/hmr/multiple-connection/rsbuild.config.ts | Basic Rsbuild configuration for the test case |
| e2e/cases/hmr/multiple-connection/index.test.ts | E2e test that verifies multiple browser tabs can establish and maintain independent HMR connections |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
stormslowly
approved these changes
Aug 14, 2025
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.

Summary
Related Links
Checklist