diff --git a/package.json b/package.json index c0f0307..fdd2621 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@adiwajshing/baileys", - "version": "3.5.0", + "version": "3.5.1", "description": "WhatsApp Web API", "homepage": "https://github.com/adiwajshing/Baileys", "main": "lib/index.js", diff --git a/src/WAConnection/0.Base.ts b/src/WAConnection/0.Base.ts index 3a3cc9a..9f96419 100644 --- a/src/WAConnection/0.Base.ts +++ b/src/WAConnection/0.Base.ts @@ -46,6 +46,7 @@ export class WAConnection extends EventEmitter { maxRetries: 10, connectCooldownMs: 4000, phoneResponseTime: 15_000, + maxQueryResponseTime: 10_000, alwaysUseTakeover: true, queryChatsTillReceived: true } @@ -280,7 +281,7 @@ export class WAConnection extends EventEmitter { timeout = setTimeout(() => { this.logger.info({ tag }, `cancelling wait for message as a response is no longer expected from the phone`) cancel({ reason: 'Not expecting a response', status: 422 }) - }, 5_000) + }, this.connectOptions.maxQueryResponseTime) this.off('connection-phone-change', listener) } } diff --git a/src/WAConnection/Constants.ts b/src/WAConnection/Constants.ts index 4e3881f..3e7bf4f 100644 --- a/src/WAConnection/Constants.ts +++ b/src/WAConnection/Constants.ts @@ -134,6 +134,8 @@ export type WAConnectOptions = { * this keeps pinging the phone to send the chats over * */ queryChatsTillReceived?: boolean + /** max time for the phone to respond to a query */ + maxQueryResponseTime?: number } /** from: https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url */ export const URL_REGEX = /[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)?/gi