Skip to content

Commit

Permalink
fix(useWebSocket): reset wsRef on close, fix #3706 (#3707)
Browse files Browse the repository at this point in the history
Co-authored-by: Doctor Wu <44631608+Doctor-wu@users.noreply.github.com>
  • Loading branch information
a982246809 and Doctor-wu committed Feb 20, 2024
1 parent 36e5ec1 commit 9a47a72
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/useWebSocket/index.ts
Expand Up @@ -192,6 +192,7 @@ export function useWebSocket<Data = any>(
resetHeartbeat()
heartbeatPause?.()
wsRef.value.close(code, reason)
wsRef.value = undefined
}

const send = (data: string | ArrayBuffer | Blob, useBuffer = true) => {
Expand Down Expand Up @@ -222,7 +223,6 @@ export function useWebSocket<Data = any>(

ws.onclose = (ev) => {
status.value = 'CLOSED'
wsRef.value = undefined
onDisconnected?.(ws, ev)

if (!explicitlyClosed && options.autoReconnect) {
Expand Down

0 comments on commit 9a47a72

Please sign in to comment.