Skip to content

fix: failed to create multiple HMR connections#5844

Merged
chenjiahan merged 3 commits intomainfrom
hmr_connections_0814
Aug 14, 2025
Merged

fix: failed to create multiple HMR connections#5844
chenjiahan merged 3 commits intomainfrom
hmr_connections_0814

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

@chenjiahan chenjiahan commented Aug 14, 2025

Summary

  • Fixed HMR failure when opening multiple browser tabs at the same time. We should use a Set to store all Web Socket connections instead of letting the new connection overwrite the previous one.
  • Added a new e2e test that verifies multiple browser pages can establish independent HMR connections and receive updates simultaneously.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings August 14, 2025 12:36
@netlify
Copy link
Copy Markdown

netlify bot commented Aug 14, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 6600485
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/689dd94849c9480007dbe9ab
😎 Deploy Preview https://deploy-preview-5844--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 58 (🔴 down 15 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chenjiahan chenjiahan merged commit 65471c7 into main Aug 14, 2025
11 checks passed
@chenjiahan chenjiahan deleted the hmr_connections_0814 branch August 14, 2025 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants