Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08412e8

Browse files
authored
fix(useWebSocket): autoreconnect when ws close (#4314)
1 parent 1d661f9 commit 08412e8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/core/useWebSocket/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export function useWebSocket<Data = any>(
231231
status.value = 'CLOSED'
232232
onDisconnected?.(ws, ev)
233233

234-
if (!explicitlyClosed && options.autoReconnect && ws === wsRef.value) {
234+
if (!explicitlyClosed && options.autoReconnect && (wsRef.value == null || ws === wsRef.value)) {
235235
const {
236236
retries = -1,
237237
delay = 1000,

0 commit comments

Comments
 (0)