This commit is contained in:
Adria Navarro 2024-03-05 13:55:07 +01:00
parent e648503e4f
commit caf142f1db
1 changed files with 12 additions and 16 deletions

View File

@ -68,23 +68,19 @@ class InMemoryQueue implements Partial<Queue> {
*/ */
async process(func: any) { async process(func: any) {
this._emitter.on("message", async () => { this._emitter.on("message", async () => {
try { if (this._messages.length <= 0) {
if (this._messages.length <= 0) { return
return }
} let msg = this._messages.shift()
let msg = this._messages.shift()
let resp = func(msg) let resp = func(msg)
if (resp.then != null) { if (resp.then != null) {
await resp await resp
} }
this._runCount++ this._runCount++
const jobId = msg?.opts?.jobId?.toString() const jobId = msg?.opts?.jobId?.toString()
if (jobId && msg?.opts?.removeOnComplete) { if (jobId && msg?.opts?.removeOnComplete) {
this._queuedJobIds.delete(jobId) this._queuedJobIds.delete(jobId)
}
} catch (e: any) {
throw e
} }
}) })
} }