mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
fix: deadlock on processNodeWithBuffer
This commit is contained in:
@@ -546,7 +546,6 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
|
||||
await sendReceipt(msg.key.remoteJid!, participant!, [msg.key.id!], type)
|
||||
|
||||
|
||||
// send ack for history message
|
||||
const isAnyHistoryMsg = getHistoryMsg(msg.message!)
|
||||
if(isAnyHistoryMsg) {
|
||||
@@ -619,14 +618,26 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
||||
|
||||
/// processes a node with the given function
|
||||
/// and adds the task to the existing buffer if we're buffering events
|
||||
const processNodeWithBuffer = (
|
||||
const processNodeWithBuffer = async(
|
||||
node: BinaryNode,
|
||||
identifier: string,
|
||||
exec: (node: BinaryNode) => Promise<any>
|
||||
) => {
|
||||
const task = exec(node)
|
||||
.catch(err => onUnexpectedError(err, identifier))
|
||||
ev.processInBuffer(task)
|
||||
const started = ev.buffer()
|
||||
if(started) {
|
||||
await execTask()
|
||||
if(started) {
|
||||
await ev.flush()
|
||||
}
|
||||
} else {
|
||||
const task = execTask()
|
||||
ev.processInBuffer(task)
|
||||
}
|
||||
|
||||
function execTask() {
|
||||
return exec(node)
|
||||
.catch(err => onUnexpectedError(err, identifier))
|
||||
}
|
||||
}
|
||||
|
||||
// called when all offline notifs are handled
|
||||
|
||||
Reference in New Issue
Block a user