diff --git a/src/WAConnection/Base.ts b/src/WAConnection/Base.ts index 50b0a25..b09d6d3 100644 --- a/src/WAConnection/Base.ts +++ b/src/WAConnection/Base.ts @@ -65,8 +65,9 @@ export default class WAConnectionBase { this.close() if ((error === 'lost' || error === 'closed') && this.autoReconnect) { await this.reconnectLoop () + } else if (this.unexpectedDisconnectCallback) { + this.unexpectedDisconnectCallback (error) } - if (this.unexpectedDisconnectCallback) this.unexpectedDisconnectCallback (error) } /** Set the callback for unexpected disconnects including take over events, log out events etc. */ setOnUnexpectedDisconnect(callback: (error: string) => void) {