Skip to content

Commit 0f58b6c

Browse files
authored
fix: undefined window throwing error on websocket close (#155)
1 parent b1b745e commit 0f58b6c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/simple_socketio.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export default class SimpleSocketIOClient {
250250
this.reconnecting = false;
251251
this.webSocket?.close();
252252
this.webSocket = undefined;
253-
if (window?.addEventListener) {
253+
if (typeof window === "object" && window.addEventListener) {
254254
window.addEventListener("online", this.attemptReconnect.bind(this), {
255255
once: true,
256256
});

0 commit comments

Comments
 (0)