Result
Awaiting job results.
Awaiting job results.
const value = await queue.result(
id: string,
options?: { timeoutMs?: number; pollMs?: number },
): Promise<R>;Resolves with the task's return value once the job finishes. Rejects with
JobFailedError if the job fails or dead-letters, JobCancelledError if it
was cancelled, or ResultTimeoutError once the optional timeoutMs (default
30000) elapses before a terminal state is reached. pollMs (default 50) sets
the store poll interval.
const id = queue.enqueue("add", [2, 3]);
const sum = await queue.result(id); // 5
const sum2 = await queue.result(id, { timeoutMs: 5000 }); // throws on timeoutThe result is deserialized with the queue's serializer. Any process sharing the storage can await a result by id — the waiter polls the store.
result is for awaiting one job. To scan many jobs use
listJobs; for aggregate outcomes use
getMetrics.