sindresorhus / p-queue

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

latest update causes all instances of `add` to return response | void #175

Closed vidarc closed 1 year ago

vidarc commented 1 year ago
import PQueue from 'p-queue'

const queue = new PQueue();

// has type Promise<string | void>
const result = queue.add(() => 'testing');

I would initially expect result to have type of Promise<string>. This commit https://github.com/sindresorhus/p-queue/commit/81846550274256011a2d55b06aeb36b23877eb43 seems to have changed that behavior.

If I'm reading the types correctly, doing

queue.add(() => 'testing', { throwOnTimeout: true })

should bring back the old typing, but it doesn't.

sindresorhus commented 1 year ago

// @Richienb

Richienb commented 1 year ago

Added type tests

beeequeue commented 1 year ago

This is still occurring on 7.3.4. See https://github.com/BeeeQueue/dota-matches-api/actions/runs/4212473470/jobs/7311519688

Richienb commented 1 year ago

This is still occurring on 7.3.4. See BeeeQueue/dota-matches-api/actions/runs/4212473470/jobs/7311519688

The p-queue API could be improved. For now, pass throwOnTimeout: true as an option.

tylerhellner commented 1 month ago

Still happening on the current release.