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)
|
await sendReceipt(msg.key.remoteJid!, participant!, [msg.key.id!], type)
|
||||||
|
|
||||||
|
|
||||||
// send ack for history message
|
// send ack for history message
|
||||||
const isAnyHistoryMsg = getHistoryMsg(msg.message!)
|
const isAnyHistoryMsg = getHistoryMsg(msg.message!)
|
||||||
if(isAnyHistoryMsg) {
|
if(isAnyHistoryMsg) {
|
||||||
@@ -619,14 +618,26 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
|
|||||||
|
|
||||||
/// processes a node with the given function
|
/// processes a node with the given function
|
||||||
/// and adds the task to the existing buffer if we're buffering events
|
/// and adds the task to the existing buffer if we're buffering events
|
||||||
const processNodeWithBuffer = (
|
const processNodeWithBuffer = async(
|
||||||
node: BinaryNode,
|
node: BinaryNode,
|
||||||
identifier: string,
|
identifier: string,
|
||||||
exec: (node: BinaryNode) => Promise<any>
|
exec: (node: BinaryNode) => Promise<any>
|
||||||
) => {
|
) => {
|
||||||
const task = exec(node)
|
const started = ev.buffer()
|
||||||
.catch(err => onUnexpectedError(err, identifier))
|
if(started) {
|
||||||
ev.processInBuffer(task)
|
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
|
// called when all offline notifs are handled
|
||||||
|
|||||||
Reference in New Issue
Block a user