From a681fdeee1fa117f51230c538a856c2f4618a753 Mon Sep 17 00:00:00 2001 From: huzibaca Date: Tue, 12 Nov 2024 19:34:53 +0800 Subject: [PATCH] fix: undefined error --- src/utils/websocket.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/websocket.ts b/src/utils/websocket.ts index 9721341..5348426 100644 --- a/src/utils/websocket.ts +++ b/src/utils/websocket.ts @@ -23,8 +23,10 @@ export const createSockette = ( remainRetryCount -= 1; if (remainRetryCount >= 0) { - this.close(); - this.reconnect(); + if (this instanceof Sockette) { + this.close(); + this.reconnect(); + } } else { opt.onerror?.call(this, ev); }