sindresorhus / p-queue

Promise queue with concurrency control
MIT License
3.48k stars 185 forks source link

Timeout option question #183

Open Vedinsoh opened 1 year ago

Vedinsoh commented 1 year ago

Documentation mentions the following:

Per-operation timeout in milliseconds. Operations fulfill once timeout elapses if they haven't already.

Does that timeout apply to operations waiting in the queue that didn't start yet, those that are running (pending) or both? It's unclear from the text.

alexwforsythe commented 4 days ago

When you add an operation to the queue, it gets wrapped in an anonymous function that does some prep work before kicking off your code. It's this wrapper that sets up the timeout handler, so the timer doesn't begin until your operation has been dequeued and started!

There doesn't appear to be any way to set a "pending" timeout—that is, a timer that begins when you add the operation and gets cleared if the operation starts before the timer elapses.