mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
bug fixes
This commit is contained in:
@@ -214,7 +214,7 @@ export class WAConnection extends EventEmitter {
|
|||||||
|
|
||||||
const response = await this.waitForMessage(tag, json, timeoutMs)
|
const response = await this.waitForMessage(tag, json, timeoutMs)
|
||||||
if (expect200 && response.status && Math.floor(+response.status / 100) !== 2) {
|
if (expect200 && response.status && Math.floor(+response.status / 100) !== 2) {
|
||||||
if (response.status >= 500) {
|
if (response.status === 599) {
|
||||||
this.unexpectedDisconnect (DisconnectReason.badSession)
|
this.unexpectedDisconnect (DisconnectReason.badSession)
|
||||||
const response = await this.query ({json, binaryTags, tag, timeoutMs, expect200, waitForOpen})
|
const response = await this.query ({json, binaryTags, tag, timeoutMs, expect200, waitForOpen})
|
||||||
return response
|
return response
|
||||||
|
|||||||
@@ -57,8 +57,9 @@ export class WAConnection extends Base {
|
|||||||
|
|
||||||
return this
|
return this
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const loggedOut = error instanceof BaileysError && error.status >= 400
|
const loggedOut = error instanceof BaileysError && error.status === 401
|
||||||
if (loggedOut && this.cancelReconnect) this.cancelReconnect ()
|
if (loggedOut && this.cancelReconnect) this.cancelReconnect ()
|
||||||
|
|
||||||
this.closeInternal (loggedOut ? 'invalid_session' : error.message)
|
this.closeInternal (loggedOut ? 'invalid_session' : error.message)
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
@@ -273,8 +274,8 @@ export class WAConnection extends Base {
|
|||||||
this.cancelReconnect = null
|
this.cancelReconnect = null
|
||||||
break
|
break
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// don't continue reconnecting if error is 400
|
// don't continue reconnecting if error is 401
|
||||||
if (error instanceof BaileysError && error.status >= 400) {
|
if (error instanceof BaileysError && error.status === 401) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
this.log (`error in reconnecting: ${error}, reconnecting...`, MessageLogLevel.info)
|
this.log (`error in reconnecting: ${error}, reconnecting...`, MessageLogLevel.info)
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export enum DisconnectReason {
|
|||||||
/** The connection was lost, called when the server stops responding to requests */
|
/** The connection was lost, called when the server stops responding to requests */
|
||||||
lost = 'lost',
|
lost = 'lost',
|
||||||
/** When WA Web is opened elsewhere & this session is disconnected */
|
/** When WA Web is opened elsewhere & this session is disconnected */
|
||||||
replaced = 'intentional',
|
replaced = 'replaced',
|
||||||
/** The credentials for the session have been invalidated, i.e. logged out either from the phone or WA Web */
|
/** The credentials for the session have been invalidated, i.e. logged out either from the phone or WA Web */
|
||||||
invalidSession = 'invalid_session',
|
invalidSession = 'invalid_session',
|
||||||
/** Received a 500 result in a query -- something has gone very wrong */
|
/** Received a 500 result in a query -- something has gone very wrong */
|
||||||
|
|||||||
Reference in New Issue
Block a user