Prevent unexpected endConnection

This commit is contained in:
Adhiraj Singh
2021-02-04 22:18:03 +05:30
parent dfaeef0db1
commit a13aabd394
2 changed files with 3 additions and 2 deletions

View File

@@ -96,7 +96,7 @@ export class WAConnection extends EventEmitter {
protected mediaConn: MediaConnInfo protected mediaConn: MediaConnInfo
protected connectionDebounceTimeout = Utils.debouncedTimeout( protected connectionDebounceTimeout = Utils.debouncedTimeout(
1000, 1000,
() => this.endConnection(DisconnectReason.timedOut) () => this.state === 'connecting' && this.endConnection(DisconnectReason.timedOut)
) )
protected messagesDebounceTimeout = Utils.debouncedTimeout(2000) protected messagesDebounceTimeout = Utils.debouncedTimeout(2000)
/** /**

View File

@@ -225,7 +225,8 @@ export class WAConnection extends Base {
ref = newRef ref = newRef
} catch (error) { } catch (error) {
this.logger.warn ({ error }, `error in QR gen`) this.logger.warn ({ error }, `error in QR gen`)
if (error.status === 429) { // too many QR requests // @ts-ignore
if (error.status === 429 && this.state !== 'open') { // too many QR requests
this.endConnection(error.message) this.endConnection(error.message)
return return
} }