From ded3ff263707eab74af33c16e2af8b34e3141946 Mon Sep 17 00:00:00 2001 From: Dan Rose Date: Mon, 17 Oct 2022 16:32:10 -0500 Subject: [PATCH] Don't reconnect if `close` issued between retries --- packages/core/useWebSocket/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/useWebSocket/index.ts b/packages/core/useWebSocket/index.ts index 42c6ee781ba..483b874d3d0 100644 --- a/packages/core/useWebSocket/index.ts +++ b/packages/core/useWebSocket/index.ts @@ -203,10 +203,12 @@ export function useWebSocket( } const _init = () => { + if (explicitlyClosed) + return + const ws = new WebSocket(url, protocols) wsRef.value = ws status.value = 'CONNECTING' - explicitlyClosed = false ws.onopen = () => { status.value = 'OPEN' @@ -290,6 +292,7 @@ export function useWebSocket( const open = () => { close() + explicitlyClosed = false retried = 0 _init() }