Skip to content

Commit 45301fe

Browse files
authored
fix(client): prevent duplicate console logs during reconnection (#6048)
1 parent 029fdbb commit 45301fe

File tree

1 file changed

+7
-2
lines changed
  • packages/core/src/client

1 file changed

+7
-2
lines changed

packages/core/src/client/hmr.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ function onClose() {
205205
return;
206206
}
207207

208-
console.info('[rsbuild] WebSocket connection lost. Reconnecting...');
208+
if (reconnectCount === 0) {
209+
console.info('[rsbuild] WebSocket connection lost. Reconnecting...');
210+
}
209211
removeListeners();
210212
socket = null;
211213
reconnectCount++;
@@ -225,7 +227,10 @@ function onError() {
225227

226228
// Establishing a WebSocket connection with the server.
227229
function connect(fallback = false) {
228-
console.info('[rsbuild] WebSocket connecting...');
230+
if (reconnectCount === 0) {
231+
console.info('[rsbuild] WebSocket connecting...');
232+
}
233+
229234
const socketUrl = formatURL(fallback);
230235
socket = new WebSocket(socketUrl);
231236
socket.addEventListener('open', onOpen);

0 commit comments

Comments
 (0)