Skip to content

Commit 3295c81

Browse files
committed
document task timeouts
1 parent 6146902 commit 3295c81

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

packages/promise-pool.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,28 @@ const pool = PromisePool
191191
```
192192

193193

194+
### Task Timeouts
195+
- *added in version `2.4`*
196+
197+
Sometimes it’s useful to configure a timeout in which a task must finish processing. A task that times out is marked as failed. You may use the `withTaskTimeout(<milliseconds>)` method to configure a task’s timeout:
198+
199+
200+
```js
201+
import { PromisePool } from '@supercharge/promise-pool'
202+
203+
await PromisePool
204+
.for(users)
205+
.withTaskTimeout(2000) // milliseconds
206+
.process(async (user, index, pool) => {
207+
// processes the `user` data
208+
})
209+
```
210+
211+
```info
212+
**Notice:** a configured timeout is configured for each task, not for the whole pool. The example configures a 2-second timeout for each task in the pool.
213+
```
214+
215+
194216
### Correspond Source Items and Their Results
195217
- *added in version `2.4`*
196218

0 commit comments

Comments
 (0)