Skip to content

Warning: Detected unsettled top-level await on queue#kill() #97

Description

@JaoodxD

The issue is similar to #90, but in my case I used kill() to empty the queue.

I was trying to implement queue abortion which should eventualy be a combination of queue.kill() and abortController.abort(). However, I noticed an unexpected behavior: the promises returned from promise-based push() was never resolved.
Additionally, the terminal displayed the following warning:

Warning: Detected unsettled top-level await at...

My question is: shouldn't fastq eventualy either resolve or reject such promises?

Here's a minimal reproducible example:

import { promise } from 'fastq'
import { setTimeout } from 'node:timers/promises'

const queue = promise(doWork, 1)
const promises = []
for(let i = 0; i < 10; i++) {
  promises.push(queue.push())
}
queue.kill()
await Promise.all(promises)

console.log('never logged')

async function doWork() {
  await setTimeout(500)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions