diff --git a/source/simple_socketio.ts b/source/simple_socketio.ts index 939ce17..430514a 100644 --- a/source/simple_socketio.ts +++ b/source/simple_socketio.ts @@ -250,7 +250,7 @@ export default class SimpleSocketIOClient { this.reconnecting = false; this.webSocket?.close(); this.webSocket = undefined; - if (window?.addEventListener) { + if (typeof window === "object" && window.addEventListener) { window.addEventListener("online", this.attemptReconnect.bind(this), { once: true, });