mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: timeout send call
This commit is contained in:
@@ -41,7 +41,7 @@ const startSock = async() => {
|
|||||||
generateHighQualityLinkPreview: true,
|
generateHighQualityLinkPreview: true,
|
||||||
// ignore all broadcast messages -- to receive the same
|
// ignore all broadcast messages -- to receive the same
|
||||||
// comment the line below out
|
// comment the line below out
|
||||||
shouldIgnoreJid: jid => isJidBroadcast(jid),
|
// shouldIgnoreJid: jid => isJidBroadcast(jid),
|
||||||
// implement to handle retries
|
// implement to handle retries
|
||||||
getMessage: async key => {
|
getMessage: async key => {
|
||||||
if(store) {
|
if(store) {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export const makeSocket = ({
|
|||||||
agent
|
agent
|
||||||
})
|
})
|
||||||
ws.setMaxListeners(0)
|
ws.setMaxListeners(0)
|
||||||
|
|
||||||
const ev = makeEventBuffer(logger)
|
const ev = makeEventBuffer(logger)
|
||||||
/** ephemeral key pair used to encrypt/decrypt communication. Unique for each connection */
|
/** ephemeral key pair used to encrypt/decrypt communication. Unique for each connection */
|
||||||
const ephemeralKeyPair = Curve.generateKeyPair()
|
const ephemeralKeyPair = Curve.generateKeyPair()
|
||||||
@@ -65,7 +66,17 @@ export const makeSocket = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bytes = noise.encodeFrame(data)
|
const bytes = noise.encodeFrame(data)
|
||||||
await sendPromise.call(ws, bytes) as Promise<void>
|
await promiseTimeout<void>(
|
||||||
|
connectTimeoutMs,
|
||||||
|
async(resolve, reject) => {
|
||||||
|
try {
|
||||||
|
await sendPromise.call(ws, bytes)
|
||||||
|
resolve()
|
||||||
|
} catch(error) {
|
||||||
|
reject(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** send a binary node */
|
/** send a binary node */
|
||||||
|
|||||||
Reference in New Issue
Block a user