mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
test: deadlock in event buffer
This commit is contained in:
@@ -307,4 +307,35 @@ describe('Event Buffer Tests', () => {
|
|||||||
|
|
||||||
expect(chats[0].unreadCount).toBeUndefined()
|
expect(chats[0].unreadCount).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should not deadlock', async() => {
|
||||||
|
const bufferedCode = ev.createBufferedFunction(
|
||||||
|
async() => {
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
ev.buffer()
|
||||||
|
|
||||||
|
let resolve: (() => void) | undefined
|
||||||
|
const initPromise = new Promise<void>(r => {
|
||||||
|
resolve = r
|
||||||
|
})
|
||||||
|
ev.processInBuffer(initPromise)
|
||||||
|
const flushPromise = ev.flush()
|
||||||
|
|
||||||
|
ev.processInBuffer(
|
||||||
|
(async() => {
|
||||||
|
await initPromise
|
||||||
|
await delay(100)
|
||||||
|
await bufferedCode()
|
||||||
|
})()
|
||||||
|
)
|
||||||
|
|
||||||
|
resolve!()
|
||||||
|
|
||||||
|
await flushPromise
|
||||||
|
|
||||||
|
// should resolve
|
||||||
|
await ev.flush()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user