Skip to content

refactor(core): rename socket server send method#7476

Merged
chenjiahan merged 1 commit intomainfrom
chenjiahan/refactor-socket-server-send-message
Apr 10, 2026
Merged

refactor(core): rename socket server send method#7476
chenjiahan merged 1 commit intomainfrom
chenjiahan/refactor-socket-server-send-message

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

  • rename the internal SocketServer.sockWrite method to sendMessage to better match its behavior of sending structured server messages to matching HMR clients
  • update the internal call sites to use the new name
  • switch non-legacy e2e cases to prefer environment.web.hot.send, while keeping the dedicated sockWrite compatibility coverage in place

Related Links

None

Copilot AI review requested due to automatic review settings April 10, 2026 06:59
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 refactors the core dev-server websocket implementation by renaming the internal SocketServer.sockWrite method to sendMessage (and its low-level sender to sendRawMessage), then updates internal call sites and modernizes non-legacy e2e coverage to use the environment-scoped HMR send API.

Changes:

  • Rename internal SocketServer.sockWritesendMessage and sendsendRawMessage, plus update internal usages.
  • Switch relevant internal triggers (watch files, dev-server hot sender, assets middleware) to call sendMessage.
  • Update non-legacy e2e tests to prefer server.environments.web.hot.send(...) while keeping explicit sockWrite compatibility tests elsewhere.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core/src/server/watchFiles.ts Update reload-on-change to use socketServer.sendMessage.
packages/core/src/server/socketServer.ts Rename internal socket broadcast API to sendMessage and raw sender to sendRawMessage.
packages/core/src/server/devServer.ts Route environment hot send implementation through socketServer.sendMessage.
packages/core/src/server/assets-middleware/index.ts Use sendMessage for HTML-triggered full reload.
e2e/cases/server/setup-middlewares/index.test.ts Prefer server.environments.web.hot.send('full-reload') in server.setup test.
e2e/cases/javascript-api/server-custom-message/index.test.ts Prefer server.environments.web.hot.send('custom', ...) for custom HMR messages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread e2e/cases/server/setup-middlewares/index.test.ts
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request renames the sockWrite method to sendMessage and the send method to sendRawMessage within the SocketServer class, updating all references across the core packages and E2E tests. Feedback was provided to optimize the sendMessage function by deferring JSON serialization until it is confirmed that active sockets are available to receive the message.

Comment thread packages/core/src/server/socketServer.ts
@chenjiahan chenjiahan merged commit c90c313 into main Apr 10, 2026
10 checks passed
@chenjiahan chenjiahan deleted the chenjiahan/refactor-socket-server-send-message branch April 10, 2026 07:10
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.

2 participants