@vercel/queue 0.1.3 → 0.1.4

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.
package/dist/index.d.mts CHANGED
@@ -205,6 +205,25 @@ interface QueueClientOptions {
205
205
  * @default JsonTransport
206
206
  */
207
207
  transport?: Transport;
208
+ /**
209
+ * Custom HTTP dispatcher passed to every `fetch()` call.
210
+ *
211
+ * Use this to plug in an undici `RetryAgent` or `Agent` for automatic
212
+ * retries on transient network errors (ECONNRESET, 429, 5xx) and
213
+ * connection pooling.
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * import { Agent, RetryAgent } from 'undici';
218
+ *
219
+ * const dispatcher = new RetryAgent(new Agent({ connections: 8 }), {
220
+ * retryAfter: true,
221
+ * });
222
+ *
223
+ * new QueueClient({ dispatcher });
224
+ * ```
225
+ */
226
+ dispatcher?: unknown;
208
227
  }
209
228
  /**
210
229
  * Options for creating a {@link PollingQueueClient}.
package/dist/index.d.ts CHANGED
@@ -205,6 +205,25 @@ interface QueueClientOptions {
205
205
  * @default JsonTransport
206
206
  */
207
207
  transport?: Transport;
208
+ /**
209
+ * Custom HTTP dispatcher passed to every `fetch()` call.
210
+ *
211
+ * Use this to plug in an undici `RetryAgent` or `Agent` for automatic
212
+ * retries on transient network errors (ECONNRESET, 429, 5xx) and
213
+ * connection pooling.
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * import { Agent, RetryAgent } from 'undici';
218
+ *
219
+ * const dispatcher = new RetryAgent(new Agent({ connections: 8 }), {
220
+ * retryAfter: true,
221
+ * });
222
+ *
223
+ * new QueueClient({ dispatcher });
224
+ * ```
225
+ */
226
+ dispatcher?: unknown;
208
227
  }
209
228
  /**
210
229
  * Options for creating a {@link PollingQueueClient}.
package/dist/index.js CHANGED
@@ -1524,6 +1524,7 @@ var ApiClient = class _ApiClient {
1524
1524
  transport;
1525
1525
  region;
1526
1526
  baseUrlResolver;
1527
+ dispatcher;
1527
1528
  constructor(options) {
1528
1529
  this.region = options.region;
1529
1530
  this.baseUrlResolver = options.resolveBaseUrl;
@@ -1531,6 +1532,7 @@ var ApiClient = class _ApiClient {
1531
1532
  this.customHeaders = options.headers || {};
1532
1533
  this.providedToken = options.token;
1533
1534
  this.transport = options.transport || new JsonTransport();
1535
+ this.dispatcher = options.dispatcher;
1534
1536
  if (options.deploymentId === null) {
1535
1537
  this.pinSends = false;
1536
1538
  this.explicitlyUnpinned = true;
@@ -1553,7 +1555,8 @@ var ApiClient = class _ApiClient {
1553
1555
  token: this.providedToken,
1554
1556
  headers: { ...this.customHeaders },
1555
1557
  deploymentId: this.explicitlyUnpinned ? null : this.resolvedDeploymentId,
1556
- transport: this.transport
1558
+ transport: this.transport,
1559
+ dispatcher: this.dispatcher
1557
1560
  });
1558
1561
  }
1559
1562
  getRegion() {
@@ -1637,9 +1640,10 @@ Cause: ${cause}`
1637
1640
  }
1638
1641
  console.debug("[VQS Debug] Request:", JSON.stringify(logData, null, 2));
1639
1642
  }
1640
- init.headers.set("User-Agent", `@vercel/queue/${"0.1.3"}`);
1643
+ init.headers.set("User-Agent", `@vercel/queue/${"0.1.4"}`);
1641
1644
  init.headers.set("Vqs-Client-Ts", (/* @__PURE__ */ new Date()).toISOString());
1642
- const response = await fetch(url, init);
1645
+ const fetchInit = this.dispatcher ? { ...init, dispatcher: this.dispatcher } : init;
1646
+ const response = await fetch(url, fetchInit);
1643
1647
  if (isDebugEnabled()) {
1644
1648
  const logData = {
1645
1649
  method,