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

Skip to content

Commit ece6a39

Browse files
authored
fix(useWebSocket): close socket connection inside WebWorker fix (#4229)
1 parent 209de63 commit ece6a39

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
@@ -198,7 +198,7 @@ export function useWebSocket<Data = any>(
198198

199199
// Status code 1000 -> Normal Closure https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
200200
const close: WebSocket['close'] = (code = 1000, reason) => {
201-
if (!isClient || !wsRef.value)
201+
if ((!isClient && !isWorker) || !wsRef.value)
202202
return
203203
explicitlyClosed = true
204204
resetHeartbeat()

0 commit comments

Comments
 (0)