minor connect change

This commit is contained in:
Adhiraj Singh
2020-10-15 17:52:54 +05:30
parent 28cf354f43
commit f1e5f3c3b5
2 changed files with 4 additions and 4 deletions

View File

@@ -203,9 +203,9 @@ export class WAConnection extends Base {
.then (newRef => ref = newRef)
.then (emitQR)
.then (regenQR)
.catch (err => {
this.logger.error (`error in QR gen: `, err)
if (err.status === 429) { // too many QR requests
.catch (error => {
this.logger.error ({ error }, `error in QR gen`)
if (error.status === 429) { // too many QR requests
this.endConnection ()
}
})

View File

@@ -34,7 +34,7 @@ export class WAConnection extends Base {
lastConnect = new Date()
const loggedOut = error instanceof BaileysError && UNAUTHORIZED_CODES.includes(error.status)
const willReconnect = !loggedOut && (tries <= (options?.maxRetries || 5)) && this.state === 'connecting'
const willReconnect = !loggedOut && (tries < options?.maxRetries) && (this.state === 'connecting')
const reason = loggedOut ? DisconnectReason.invalidSession : error.message
this.logger.warn ({ error }, `connect attempt ${tries} failed${ willReconnect ? ', retrying...' : ''}`)