@vite-hub/queue 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +17 -12
  2. package/dist/{client-CwoCdKct.js → client-B8QVg1mA.js} +46 -15
  3. package/dist/{cloudflare-client-xWteD-su.js → cloudflare-client-BoaOlFzD.js} +13 -8
  4. package/dist/{cloudflare-resource-name-Bv8Z7nDU.js → cloudflare-resource-name-Coz5CPmn.js} +1 -1
  5. package/dist/{config-Bzp1xmdh.js → config-ByKUipob.js} +4 -2
  6. package/dist/{definition-CIiFfst2.js → definition-Dorliu47.js} +9 -2
  7. package/dist/{duration-C5w_-Rf4.js → duration-CcLSF94z.js} +20 -5
  8. package/dist/{error-diagnostics-kKXseq8d.js → error-diagnostics-CsiNo_oI.js} +3 -3
  9. package/dist/{error-diagnostics-Dv6nKZQW.js → error-diagnostics-Yj8XCiya.js} +30 -6
  10. package/dist/{handler-response-CchTXVjm.js → handler-response-GFXYd6mF.js} +6 -2
  11. package/dist/index.d.ts +13 -8
  12. package/dist/index.js +4 -4
  13. package/dist/internal/runtime/cloudflare-client.d.ts +1 -1
  14. package/dist/internal/runtime/cloudflare-client.js +1 -1
  15. package/dist/internal/runtime/cloudflare-vite.d.ts +1 -1
  16. package/dist/internal/runtime/cloudflare-vite.js +9 -8
  17. package/dist/internal/runtime/local-client.d.ts +3 -3
  18. package/dist/internal/runtime/local-client.js +4 -4
  19. package/dist/internal/runtime/postgres-client.d.ts +9 -7
  20. package/dist/internal/runtime/postgres-client.js +174 -36
  21. package/dist/internal/runtime/state.d.ts +5 -3
  22. package/dist/internal/runtime/state.js +1 -1
  23. package/dist/internal/runtime/vercel-client.d.ts +1 -1
  24. package/dist/internal/runtime/vercel-client.js +24 -5
  25. package/dist/internal/runtime/worker-client.d.ts +2 -2
  26. package/dist/internal/runtime/worker-client.js +1 -1
  27. package/dist/{local-RX10a_Sq.js → local-BR4W57HU.js} +146 -97
  28. package/dist/{local-B72WRWkS.d.ts → local-DUh8sGn-.d.ts} +1 -1
  29. package/dist/{operations-CoEXxfUW.js → operations-COCpSoua.js} +11 -6
  30. package/dist/{operation-definition-CqZkx1Rm.d.ts → operations-DSslh_vK.d.ts} +169 -1
  31. package/dist/operations.d.ts +13 -4
  32. package/dist/operations.js +98 -37
  33. package/dist/retries-BSAZru9n.js +27 -0
  34. package/dist/run-handler-B_RVXMs5.js +61 -0
  35. package/dist/runtime/hosted.d.ts +1 -1
  36. package/dist/runtime/hosted.js +32 -20
  37. package/dist/{state-DqxeV11k.js → state-C-t99I4Q.js} +9 -3
  38. package/dist/{types-BevEYrUV.d.ts → types-BPs6OsRv.d.ts} +1 -1
  39. package/dist/{types-BzPGPV9z.d.ts → types-rZHAtkK0.d.ts} +74 -12
  40. package/dist/{vercel-region-DEsR1YJQ.js → vercel-region-Bp3hwRBr.js} +1 -1
  41. package/dist/vite.d.ts +3 -156
  42. package/dist/vite.js +460 -68
  43. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
- import { t as AnyOperation } from "./operation-definition-CqZkx1Rm.js";
2
- import "./local-B72WRWkS.js";
3
- import { A as QueueJobStore, d as LocalQueueJob, f as LocalQueueJobDetail, h as LocalQueueStatus, p as LocalQueueRules, w as QueueDriver } from "./types-BzPGPV9z.js";
1
+ import { t as AnyOperation } from "./operations-DSslh_vK.js";
2
+ import "./local-DUh8sGn-.js";
3
+ import { T as QueueDriver, d as LocalQueueJob, f as LocalQueueJobDetail, h as LocalQueueStatus, j as QueueJobStore, p as LocalQueueRules, z as QueueRetryDeadResult } from "./types-rZHAtkK0.js";
4
4
  interface QueueListResult {
5
5
  /** `undefined` when the runtime has not installed a Queue configuration. */
6
6
  provider?: QueueDriver;
@@ -23,6 +23,8 @@ interface QueueListResult {
23
23
  pending?: number;
24
24
  running?: number;
25
25
  }>;
26
+ /** The postgres provider only: whether this server process runs jobs. `QUEUE_WORKERS=false` sets it to `false`. */
27
+ workers?: boolean;
26
28
  }
27
29
  interface QueueJobsListInput {
28
30
  queue?: string;
@@ -57,10 +59,17 @@ interface QueueSendOperationInput {
57
59
  payload: unknown;
58
60
  queue: string;
59
61
  }
62
+ interface QueueJobsRetryInput {
63
+ /** The message ID of one job. */
64
+ id?: string;
65
+ /** With `state: "dead"` and no `id`: every dead job of this Queue Definition. */
66
+ queue?: string;
67
+ state?: "dead";
68
+ }
60
69
  /**
61
70
  * The `queue.*` operations: list and send, and the stored jobs of the local and postgres providers. `vite dev` runs
62
71
  * every job with the local provider. Cloudflare and Vercel do not let a producer read their queue, so the job
63
72
  * operations fail there.
64
73
  */
65
74
  export declare const queueOperations: readonly AnyOperation[];
66
- export type { LocalQueueJob, LocalQueueJobDetail, QueueJobsClearInput, QueueJobsListInput, QueueJobsListResult, QueueListResult, QueueSendOperationInput, QueueSendOperationResult };
75
+ export type { LocalQueueJob, LocalQueueJobDetail, QueueJobsClearInput, QueueJobsListInput, QueueJobsListResult, QueueJobsRetryInput, QueueListResult, QueueRetryDeadResult, QueueSendOperationInput, QueueSendOperationResult };
@@ -1,5 +1,5 @@
1
1
  import { r as isRecordOrFunction } from "./object-DRSmpe04.js";
2
- import { t as internalErrorDiagnostics } from "./error-diagnostics-kKXseq8d.js";
2
+ import { t as internalErrorDiagnostics } from "./error-diagnostics-CsiNo_oI.js";
3
3
  import { toJsonSchema } from "@valibot/to-json-schema";
4
4
  // ../internal/src/standard-schema.ts
5
5
  function readOwn(value, key) {
@@ -214,6 +214,21 @@ function _addIssue(context, label, dataset, config$1, other) {
214
214
  else dataset.issues = [issue];
215
215
  }
216
216
  /**
217
+ * Compares two values using the SameValueZero algorithm, which treats `NaN`
218
+ * as equal to itself unlike `===`.
219
+ *
220
+ * @param value1 The first value.
221
+ * @param value2 The second value.
222
+ *
223
+ * @returns Whether the values are equal.
224
+ *
225
+ * @internal
226
+ */
227
+ /* @__NO_SIDE_EFFECTS__ */
228
+ function _isSameValueZero(value1, value2) {
229
+ return value1 === value2 || Number.isNaN(value1) && Number.isNaN(value2);
230
+ }
231
+ /**
217
232
  * Joins multiple `expects` values with the given separator.
218
233
  *
219
234
  * @param values The `expects` values.
@@ -249,6 +264,22 @@ function _standardSchema(schema) {
249
264
  };
250
265
  return schema;
251
266
  }
267
+ /* @__NO_SIDE_EFFECTS__ */
268
+ function check(requirement, message$1) {
269
+ return {
270
+ kind: "validation",
271
+ type: "check",
272
+ reference: check,
273
+ async: false,
274
+ expects: null,
275
+ requirement,
276
+ message: message$1,
277
+ "~run"(dataset, config$1) {
278
+ if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "input", dataset, config$1);
279
+ return dataset;
280
+ }
281
+ };
282
+ }
252
283
  /**
253
284
  * Creates a description metadata action.
254
285
  *
@@ -308,6 +339,23 @@ function getDefault(schema, dataset, config$1) {
308
339
  return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
309
340
  }
310
341
  /* @__NO_SIDE_EFFECTS__ */
342
+ function literal(literal_, message$1) {
343
+ return _standardSchema({
344
+ kind: "schema",
345
+ type: "literal",
346
+ reference: literal,
347
+ expects: /* @__PURE__ */ _stringify(literal_),
348
+ async: false,
349
+ literal: literal_,
350
+ message: message$1,
351
+ "~run"(dataset, config$1) {
352
+ if (/* @__PURE__ */ _isSameValueZero(dataset.value, this.literal)) dataset.typed = true;
353
+ else _addIssue(this, "type", dataset, config$1);
354
+ return dataset;
355
+ }
356
+ });
357
+ }
358
+ /* @__NO_SIDE_EFFECTS__ */
311
359
  function optional(wrapped, default_) {
312
360
  return _standardSchema({
313
361
  kind: "schema",
@@ -477,7 +525,7 @@ function pipe(...pipe$1) {
477
525
  });
478
526
  }
479
527
  // src/operations.ts
480
- const runtime = () => import("./operations-CoEXxfUW.js");
528
+ const runtime = () => import("./operations-COCpSoua.js");
481
529
  function defineQueueOperation(definition) {
482
530
  return defineOperation({
483
531
  ...definition,
@@ -553,6 +601,44 @@ function formatJob({ job }) {
553
601
  ""
554
602
  ].join("\n");
555
603
  }
604
+ const jobsList = defineQueueOperation({
605
+ cli: {
606
+ command: "jobs list",
607
+ format: formatJobs,
608
+ namespace: "queue"
609
+ },
610
+ description: "List the stored Queue jobs, newest first: pending, running, and dead jobs, from the local or postgres provider. In `vite dev` every job runs in the dev server, so this lists them for any provider.",
611
+ input: /* @__PURE__ */ strictObject({
612
+ queue: /* @__PURE__ */ optional(queueName),
613
+ state: /* @__PURE__ */ optional(/* @__PURE__ */ picklist([
614
+ "dead",
615
+ "pending",
616
+ "running"
617
+ ]))
618
+ }),
619
+ kind: "read",
620
+ name: "queue.jobs-list",
621
+ run: async (input) => (await runtime()).listQueueJobs(input)
622
+ });
623
+ const jobsShow = defineQueueOperation({
624
+ cli: {
625
+ command: "jobs get",
626
+ format: formatJob,
627
+ namespace: "queue",
628
+ positional: ["id"]
629
+ },
630
+ description: "Show one stored Queue job by message ID, with its payload, attempts, and last error.",
631
+ input: /* @__PURE__ */ strictObject({ id: jobId }),
632
+ kind: "read",
633
+ name: "queue.jobs-show",
634
+ run: async (input) => (await runtime()).showQueueJob(input.id)
635
+ });
636
+ function formatRetry(result) {
637
+ if ("job" in result) return `${JSON.stringify(result, null, 2)}\n`;
638
+ const retried = `Retried ${result.retried} dead job${result.retried === 1 ? "" : "s"}.\n`;
639
+ if (!result.skipped.length) return retried;
640
+ return `${retried}Skipped ${result.skipped.length} dead job${result.skipped.length === 1 ? "" : "s"} whose idempotency key a newer job holds:\n${result.skipped.join("\n")}\n`;
641
+ }
556
642
  /**
557
643
  * The `queue.*` operations: list and send, and the stored jobs of the local and postgres providers. `vite dev` runs
558
644
  * every job with the local provider. Cloudflare and Vercel do not let a producer read their queue, so the job
@@ -561,50 +647,25 @@ function formatJob({ job }) {
561
647
  const queueOperations = [
562
648
  list,
563
649
  send,
564
- defineQueueOperation({
565
- cli: {
566
- command: "jobs list",
567
- format: formatJobs,
568
- namespace: "queue"
569
- },
570
- description: "List the stored Queue jobs, newest first: pending, running, and dead jobs, from the local or postgres provider. In `vite dev` every job runs in the dev server, so this lists them for any provider.",
571
- input: /* @__PURE__ */ strictObject({
572
- queue: /* @__PURE__ */ optional(queueName),
573
- state: /* @__PURE__ */ optional(/* @__PURE__ */ picklist([
574
- "dead",
575
- "pending",
576
- "running"
577
- ]))
578
- }),
579
- kind: "read",
580
- name: "queue.jobs-list",
581
- run: async (input) => (await runtime()).listQueueJobs(input)
582
- }),
583
- defineQueueOperation({
584
- cli: {
585
- command: "jobs get",
586
- format: formatJob,
587
- namespace: "queue",
588
- positional: ["id"]
589
- },
590
- description: "Show one stored Queue job by message ID, with its payload, attempts, and last error.",
591
- input: /* @__PURE__ */ strictObject({ id: jobId }),
592
- kind: "read",
593
- name: "queue.jobs-show",
594
- run: async (input) => (await runtime()).showQueueJob(input.id)
595
- }),
650
+ jobsList,
651
+ jobsShow,
596
652
  defineQueueOperation({
597
653
  cli: {
598
654
  command: "jobs retry",
655
+ format: formatRetry,
599
656
  namespace: "queue",
600
657
  positional: ["id"]
601
658
  },
602
- description: "Run a stored Queue job now. A dead job gets a new set of attempts. The call returns before the handler ends.",
603
- input: /* @__PURE__ */ strictObject({ id: jobId }),
659
+ description: "Run a stored Queue job now, by message ID. A dead job gets a new set of attempts. With `queue` and `state: dead` instead of an ID, every dead job of that queue runs again, in batches of 500, and a dead job whose idempotency key a newer job holds is skipped. The call returns before the handlers end.",
660
+ input: /* @__PURE__ */ pipe(/* @__PURE__ */ strictObject({
661
+ id: /* @__PURE__ */ optional(jobId),
662
+ queue: /* @__PURE__ */ optional(queueName),
663
+ state: /* @__PURE__ */ optional(/* @__PURE__ */ pipe(/* @__PURE__ */ literal("dead"), /* @__PURE__ */ description("With `queue`: retry every dead job of that queue.")))
664
+ }), /* @__PURE__ */ check((input) => input.id === void 0 ? input.queue !== void 0 && input.state === "dead" : input.queue === void 0 && input.state === void 0, "Pass a job `id`, or `queue` with `state: \"dead\"`.")),
604
665
  invoke: true,
605
666
  kind: "write",
606
667
  name: "queue.jobs-retry",
607
- run: async (input) => (await runtime()).retryQueueJob(input.id)
668
+ run: async (input) => input.id === void 0 ? (await runtime()).retryDeadQueueJobs(input.queue) : (await runtime()).retryQueueJob(input.id)
608
669
  }),
609
670
  defineQueueOperation({
610
671
  cli: {
@@ -0,0 +1,27 @@
1
+ import { parseDuration } from "@vite-hub/runtime";
2
+ // src/internal/retries.ts
3
+ const defaultQueueRetries = {
4
+ backoff: "exponential",
5
+ delay: "10 seconds",
6
+ limit: 3
7
+ };
8
+ const cloudflareMaxRetryDelayMs = 432e5;
9
+ function queueRetryPolicy(retries) {
10
+ const backoff = retries?.backoff ?? defaultQueueRetries.backoff;
11
+ const first = parseDuration(retries?.delay ?? defaultQueueRetries.delay, "retries.delay");
12
+ return {
13
+ delayMs: (attempts) => Math.min(backoff === "exponential" ? first * 2 ** Math.max(0, attempts - 1) : first, cloudflareMaxRetryDelayMs),
14
+ limit: retries?.limit ?? defaultQueueRetries.limit
15
+ };
16
+ }
17
+ /** Returns why `retries` is invalid, or `undefined`. */
18
+ function invalidQueueRetries(retries) {
19
+ if (typeof retries !== "object" || retries === null || Array.isArray(retries)) return "`retries` must be an object such as `{ limit: 5, delay: \"30s\" }`.";
20
+ const unknownKey = Object.keys(retries).find((key) => key !== "backoff" && key !== "delay" && key !== "limit");
21
+ if (unknownKey) return `\`retries\` does not support the "${unknownKey}" option.`;
22
+ const { backoff, delay, limit } = retries;
23
+ if (limit !== void 0 && !(Number.isInteger(limit) && limit >= 0 && limit <= 100)) return "`retries.limit` must be a whole number from 0 to 100.";
24
+ if (backoff !== void 0 && backoff !== "constant" && backoff !== "exponential") return "`retries.backoff` must be \"constant\" or \"exponential\".";
25
+ if (delay !== void 0) parseDuration(delay, "retries.delay");
26
+ }
27
+ export { queueRetryPolicy as n, invalidQueueRetries as t };
@@ -0,0 +1,61 @@
1
+ import { t as queueErrorDiagnostics } from "./error-diagnostics-Yj8XCiya.js";
2
+ import { t as checkQueueHandlerResponse } from "./handler-response-GFXYd6mF.js";
3
+ import { parseDuration } from "@vite-hub/runtime";
4
+ import { runInRunScopes } from "@vite-hub/runtime/internal/run-scope";
5
+ // src/internal/run-handler.ts
6
+ const defaultQueueTimeout = "15 minutes";
7
+ const maxTimerDelay = 2147483647;
8
+ /**
9
+ * Runs one attempt of a Queue handler inside the run scopes and checks its HTTP response there, so a failed status or a
10
+ * timeout drops the writes that the attempt staged, such as Workspace writes. When the Definition's `timeout` passes,
11
+ * `job.signal` aborts and the attempt fails with `QUEUE_JOB_TIMEOUT`, so the provider frees the slot and retries the
12
+ * job. A handler that ignores the signal keeps running in the background.
13
+ */
14
+ async function runQueueJob(definition, job, queue) {
15
+ await runInRunScopes(async () => {
16
+ checkQueueHandlerResponse(await runWithTimeout(definition, job, queue));
17
+ });
18
+ }
19
+ /** Runs one attempt of a Queue handler inside the run scopes, with its timeout. Returns what the handler returned. */
20
+ function runQueueHandler(definition, job, queue) {
21
+ return runInRunScopes(() => runWithTimeout(definition, job, queue));
22
+ }
23
+ async function runWithTimeout(definition, job, queue) {
24
+ const timeout = definition.timeout ?? defaultQueueTimeout;
25
+ const deadline = performance.now() + Math.ceil(parseDuration(timeout, "timeout"));
26
+ const controller = new AbortController();
27
+ const abort = () => {
28
+ const error = queueErrorDiagnostics.QUEUE_JOB_TIMEOUT({
29
+ queue,
30
+ timeout: String(timeout)
31
+ });
32
+ controller.abort(error);
33
+ return error;
34
+ };
35
+ let timer;
36
+ const expired = new Promise((_resolve, reject) => {
37
+ const arm = () => {
38
+ timer = setTimeout(() => {
39
+ if (performance.now() < deadline) return arm();
40
+ reject(abort());
41
+ }, Math.min(Math.max(Math.ceil(deadline - performance.now()), 1), maxTimerDelay));
42
+ timer.unref?.();
43
+ };
44
+ arm();
45
+ });
46
+ const run = (async () => {
47
+ const result = await definition.handler({
48
+ ...job,
49
+ signal: controller.signal
50
+ });
51
+ if (controller.signal.aborted) throw controller.signal.reason;
52
+ if (performance.now() >= deadline) throw abort();
53
+ return result;
54
+ })();
55
+ try {
56
+ return await Promise.race([run, expired]);
57
+ } finally {
58
+ clearTimeout(timer);
59
+ }
60
+ }
61
+ export { runQueueJob as n, runQueueHandler as t };
@@ -1,4 +1,4 @@
1
- import { x as QueueDefinition } from "../types-BzPGPV9z.js";
1
+ import { S as QueueDefinition } from "../types-rZHAtkK0.js";
2
2
  export declare const hostedVercelWaitUntil: (promise: Promise<unknown>) => void | undefined;
3
3
  /** Handle one Vercel Queue delivery. The generated consumer route is a Fetchable module that passes its Request here. */
4
4
  export declare function handleHostedVercelQueueCallback(request: Request, name: string, definition: QueueDefinition): Promise<Response>;
@@ -1,49 +1,61 @@
1
- import { t as queueErrorDiagnostics } from "../error-diagnostics-Dv6nKZQW.js";
2
- import { i as reportQueueDeliveryError, r as isNonRetryableQueueError, t as checkQueueHandlerResponse } from "../handler-response-CchTXVjm.js";
3
- import { n as dynamicQueue } from "../client-CwoCdKct.js";
4
- import { runInRunScopes } from "@vite-hub/runtime/internal/run-scope";
1
+ import { t as queueErrorDiagnostics } from "../error-diagnostics-Yj8XCiya.js";
2
+ import { i as reportQueueDeliveryError, r as isNonRetryableQueueError } from "../handler-response-GFXYd6mF.js";
3
+ import { n as queueRetryPolicy } from "../retries-BSAZru9n.js";
4
+ import { n as runQueueJob } from "../run-handler-B_RVXMs5.js";
5
+ import { r as loadQueueClient } from "../client-B8QVg1mA.js";
5
6
  import { waitUntil } from "@vercel/functions";
6
7
  // src/runtime/hosted.ts
7
8
  const hostedVercelWaitUntil = waitUntil;
8
- function createVercelJobHandler(definition) {
9
+ const vercelMaxRetryDelaySeconds = 3600;
10
+ function vercelDeliveryMetadata(metadata) {
11
+ return metadata;
12
+ }
13
+ function createVercelJobHandler(name, definition, limit) {
9
14
  return async (payload, metadata) => {
10
- const meta = metadata;
11
- await runInRunScopes(async () => {
12
- checkQueueHandlerResponse(await definition.handler({
13
- attempts: typeof meta?.deliveryCount === "number" ? meta.deliveryCount : 1,
14
- id: typeof meta?.messageId === "string" ? meta.messageId : "vercel-message",
15
- metadata,
16
- payload
17
- }));
18
- });
15
+ const meta = vercelDeliveryMetadata(metadata);
16
+ const attempts = meta?.deliveryCount ?? 1;
17
+ if (attempts > limit + 1) return;
18
+ await runQueueJob(definition, {
19
+ attempts,
20
+ id: meta?.messageId ?? "vercel-message",
21
+ metadata,
22
+ payload
23
+ }, name);
19
24
  };
20
25
  }
21
- function createVercelCallbackOptions(name, options) {
26
+ function createVercelCallbackOptions(name, definition, retries) {
27
+ const options = definition.callbackOptions;
22
28
  const retry = options?.retry;
23
29
  return {
24
30
  ...options,
25
31
  retry(error, metadata) {
26
- const meta = metadata;
32
+ const meta = vercelDeliveryMetadata(metadata);
33
+ const attempts = Math.max(1, meta?.deliveryCount ?? 1);
27
34
  reportQueueDeliveryError(error, {
28
- attempts: typeof meta?.deliveryCount === "number" ? meta.deliveryCount : 1,
29
- id: typeof meta?.messageId === "string" ? meta.messageId : "vercel-message",
35
+ attempts,
36
+ id: meta?.messageId ?? "vercel-message",
30
37
  provider: "vercel",
31
38
  queue: name
32
39
  });
40
+ if (attempts > retries.limit) return { acknowledge: true };
33
41
  const directive = retry?.(error, metadata);
34
42
  if (directive !== void 0) return directive;
35
43
  if (isNonRetryableQueueError(error)) return { acknowledge: true };
44
+ const remainingSeconds = meta?.expiresAt ? Math.floor((meta.expiresAt.getTime() - Date.now()) / 1e3) - 1 : vercelMaxRetryDelaySeconds;
45
+ if (remainingSeconds < 0) return { acknowledge: true };
46
+ return { afterSeconds: Math.min(Math.ceil(retries.delayMs(attempts) / 1e3), vercelMaxRetryDelaySeconds, remainingSeconds) };
36
47
  }
37
48
  };
38
49
  }
39
50
  /** Handle one Vercel Queue delivery. The generated consumer route is a Fetchable module that passes its Request here. */
40
51
  async function handleHostedVercelQueueCallback(request, name, definition) {
41
- const queue = await dynamicQueue.use(name);
52
+ const queue = await loadQueueClient(name);
42
53
  if (queue.provider !== "vercel") throw queueErrorDiagnostics.QUEUE_DRIVER_MISMATCH({
43
54
  driver: queue.provider,
44
55
  expected: "vercel"
45
56
  });
46
- const result = await queue.callback(createVercelJobHandler(definition), createVercelCallbackOptions(name, definition.callbackOptions))(request);
57
+ const retries = queueRetryPolicy(definition.retries);
58
+ const result = await queue.callback(createVercelJobHandler(name, definition, retries.limit), createVercelCallbackOptions(name, definition, retries))(request);
47
59
  if (result instanceof Response) return result;
48
60
  return result === void 0 ? new Response(null, { status: 204 }) : Response.json(result);
49
61
  }
@@ -1,5 +1,5 @@
1
1
  import { n as isRecord } from "./object-DRSmpe04.js";
2
- import { t as queueErrorDiagnostics } from "./error-diagnostics-Dv6nKZQW.js";
2
+ import { t as queueErrorDiagnostics } from "./error-diagnostics-Yj8XCiya.js";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
  // ../internal/src/runtime/cloudflare-env-lookup.ts
5
5
  /** The key of the AsyncLocalStorage store on `globalThis`. Every bundled copy of this module shares the store. */
@@ -117,6 +117,7 @@ let runtimeConfig;
117
117
  let runtimeClientFactory;
118
118
  let registryOverride;
119
119
  let jobStore;
120
+ let jobWorkers;
120
121
  const queueEventStorage = new AsyncLocalStorage();
121
122
  let queueEventDefaults;
122
123
  const queueClientCache = /* @__PURE__ */ new Map();
@@ -133,8 +134,13 @@ function setQueueRuntimeConfig(config, createClient) {
133
134
  * The stored jobs of a provider that does not keep them in this package's process state. The generated server sets it
134
135
  * for the postgres provider, so the Queue operations read jobs without importing the Postgres driver.
135
136
  */
136
- function setQueueRuntimeJobStore(store) {
137
+ function setQueueRuntimeJobStore(store, workers) {
137
138
  jobStore = store;
139
+ jobWorkers = store ? workers : void 0;
140
+ }
141
+ /** Whether this process runs the jobs of the store that `setQueueRuntimeJobStore()` set. `QUEUE_WORKERS=false` turns it off. */
142
+ function getQueueRuntimeJobWorkers() {
143
+ return jobWorkers;
138
144
  }
139
145
  async function getQueueRuntimeJobStore() {
140
146
  return await jobStore?.();
@@ -190,4 +196,4 @@ async function loadQueueDefinition(name) {
190
196
  if (isQueueDefinition(loaded)) return loaded;
191
197
  if (isRecord(loaded) && Object.hasOwn(loaded, "default") && isQueueDefinition(loaded.default)) return loaded.default;
192
198
  }
193
- export { runWithActiveCloudflareEnv as _, getQueueRuntimeEvent as a, loadQueueDefinition as c, setQueueRuntimeConfig as d, setQueueRuntimeEventDefaults as f, resolveWaitUntil as g, createCloudflareRuntimeEvent as h, getQueueRuntimeConfig as i, missingQueueDefinitionError as l, setQueueRuntimeRegistry as m, getOrCreateQueueClient as n, getQueueRuntimeJobStore as o, setQueueRuntimeJobStore as p, getQueueRuntimeClientFactory as r, listQueueDefinitionNames as s, enterQueueRuntimeEvent as t, runWithQueueRuntimeEvent as u, getCloudflareEnv as v };
199
+ export { resolveWaitUntil as _, getQueueRuntimeEvent as a, listQueueDefinitionNames as c, runWithQueueRuntimeEvent as d, setQueueRuntimeConfig as f, createCloudflareRuntimeEvent as g, setQueueRuntimeRegistry as h, getQueueRuntimeConfig as i, loadQueueDefinition as l, setQueueRuntimeJobStore as m, getOrCreateQueueClient as n, getQueueRuntimeJobStore as o, setQueueRuntimeEventDefaults as p, getQueueRuntimeClientFactory as r, getQueueRuntimeJobWorkers as s, enterQueueRuntimeEvent as t, missingQueueDefinitionError as u, runWithActiveCloudflareEnv as v, getCloudflareEnv as y };
@@ -1,4 +1,4 @@
1
- import { R as ResolvedQueueOptions, T as QueueDriverOptions } from "./types-BzPGPV9z.js";
1
+ import { E as QueueDriverOptions, U as ResolvedQueueOptions } from "./types-rZHAtkK0.js";
2
2
  interface QueueDevelopmentOptions {
3
3
  development?: boolean;
4
4
  }