diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 50814ccd..0f519fb7 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -39,6 +39,10 @@ Read more: output via logging (thanks @wineTGH). - Fix race condition when multiple workers attempt to initialise the database at the same time +- `helpers.abortSignal` is no longer typed as `| undefined`. It is still + experimental! +- `helpers.abortPromise` added; will reject when `abortSignal` aborts (useful + for `Promise.race()`) ## v0.16.6 diff --git a/website/docs/tasks.md b/website/docs/tasks.md index f0e46d6b..644d883c 100644 --- a/website/docs/tasks.md +++ b/website/docs/tasks.md @@ -36,9 +36,13 @@ Each task function is passed two arguments: shouldn't need this - `getQueueName()` — get the name of the queue the job is in (may or may not return a promise - recommend you always `await` it) - - `abortSignal` — could be an `AbortSignal` or `undefined`; if set, use - this to abort your task early on graceful shutdown (can be passed to a - number of asynchronous Node.js methods) + - `abortSignal` — could be an `AbortSignal`, or `undefined` if not + supported by this release of worker; if set, use this to abort your task + early on graceful shutdown (can be passed to a number of asynchronous + Node.js methods) + - `abortPromise` — if present, a promise that will reject when + `abortSignal` aborts; convenient for exiting your task when the abortSignal + fires: `Promise.race([abortPromise, doYourThing()])` - `withPgClient` — a helper to use to get a database client - `query(sql, values)` — a convenience wrapper for `withPgClient(pgClient => pgClient.query(sql, values))`