@vercel/queue 0.1.3 → 0.1.5
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/README.md +9 -9
- package/dist/index.d.mts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,7 +92,7 @@ await send(
|
|
|
92
92
|
{ message: "Hello world" },
|
|
93
93
|
{
|
|
94
94
|
idempotencyKey: "unique-key", // Prevent duplicate messages
|
|
95
|
-
retentionSeconds: 3600, // 1 hour TTL (default: 24h)
|
|
95
|
+
retentionSeconds: 3600, // 1 hour TTL (default: 24h, max: 7d)
|
|
96
96
|
delaySeconds: 60, // Delay delivery by 1 minute
|
|
97
97
|
region: "sfo1", // Top-level send() only — not available on QueueClient.send()
|
|
98
98
|
},
|
|
@@ -274,7 +274,7 @@ Multiple route files for the same topic create separate consumer groups — each
|
|
|
274
274
|
|
|
275
275
|
### 3. Retry and Backoff
|
|
276
276
|
|
|
277
|
-
When a handler throws, the message is not acknowledged and becomes available for redelivery after the `retryAfterSeconds` interval configured in `vercel.json`. Retries continue until the handler succeeds or the message expires (default: 24 hours).
|
|
277
|
+
When a handler throws, the message is not acknowledged and becomes available for redelivery after the `retryAfterSeconds` interval configured in `vercel.json`. Retries continue until the handler succeeds or the message expires (default: 24 hours, max: 7 days).
|
|
278
278
|
|
|
279
279
|
For finer control over retry timing, pass a `retry` option. You can also set `visibilityTimeoutSeconds` to control how long the message is locked during processing (default: 300):
|
|
280
280
|
|
|
@@ -570,11 +570,11 @@ All error types:
|
|
|
570
570
|
|
|
571
571
|
#### Publishing Messages
|
|
572
572
|
|
|
573
|
-
| Parameter | Default | Min | Max
|
|
574
|
-
| ------------------ | ------------ | --- |
|
|
575
|
-
| `retentionSeconds` | 86,400 (24h) | 60 |
|
|
576
|
-
| `delaySeconds` | 0 | 0 |
|
|
577
|
-
| `idempotencyKey` | — | — | —
|
|
573
|
+
| Parameter | Default | Min | Max | Notes |
|
|
574
|
+
| ------------------ | ------------ | --- | ------------ | ----------------------------------- |
|
|
575
|
+
| `retentionSeconds` | 86,400 (24h) | 60 | 604,800 (7d) | Message TTL |
|
|
576
|
+
| `delaySeconds` | 0 | 0 | 432,000 (5d) | Cannot exceed retention |
|
|
577
|
+
| `idempotencyKey` | — | — | — | Dedup window: `min(retention, 24h)` |
|
|
578
578
|
|
|
579
579
|
#### Receiving Messages
|
|
580
580
|
|
|
@@ -620,8 +620,8 @@ import { send } from "@vercel/queue";
|
|
|
620
620
|
|
|
621
621
|
const { messageId } = await send("my-topic", payload, {
|
|
622
622
|
idempotencyKey: "unique-key", // Dedup window: min(retention, 24h)
|
|
623
|
-
retentionSeconds: 3600, // Message TTL (default: 86400)
|
|
624
|
-
delaySeconds: 60, // Delay before visible (default: 0)
|
|
623
|
+
retentionSeconds: 3600, // Message TTL (default: 86400, max: 604800)
|
|
624
|
+
delaySeconds: 60, // Delay before visible (default: 0, max: 5d)
|
|
625
625
|
headers: { "X-Custom": "val" }, // Custom headers
|
|
626
626
|
region: "sfo1", // Override the auto-detected region for this send
|
|
627
627
|
});
|
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}.
|
|
@@ -241,7 +260,7 @@ interface SendOptions {
|
|
|
241
260
|
* Message retention time in seconds. After this period, the message expires.
|
|
242
261
|
* @default 86400 (24 hours)
|
|
243
262
|
* @minimum 60 (1 minute)
|
|
244
|
-
* @maximum
|
|
263
|
+
* @maximum 604800 (7 days)
|
|
245
264
|
*/
|
|
246
265
|
retentionSeconds?: number;
|
|
247
266
|
/**
|
|
@@ -249,7 +268,7 @@ interface SendOptions {
|
|
|
249
268
|
* The message will not be visible to consumers until the delay has passed.
|
|
250
269
|
* @default 0
|
|
251
270
|
* @minimum 0
|
|
252
|
-
* @maximum
|
|
271
|
+
* @maximum 432000 (5 days, and cannot exceed retentionSeconds)
|
|
253
272
|
*/
|
|
254
273
|
delaySeconds?: number;
|
|
255
274
|
/**
|
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}.
|
|
@@ -241,7 +260,7 @@ interface SendOptions {
|
|
|
241
260
|
* Message retention time in seconds. After this period, the message expires.
|
|
242
261
|
* @default 86400 (24 hours)
|
|
243
262
|
* @minimum 60 (1 minute)
|
|
244
|
-
* @maximum
|
|
263
|
+
* @maximum 604800 (7 days)
|
|
245
264
|
*/
|
|
246
265
|
retentionSeconds?: number;
|
|
247
266
|
/**
|
|
@@ -249,7 +268,7 @@ interface SendOptions {
|
|
|
249
268
|
* The message will not be visible to consumers until the delay has passed.
|
|
250
269
|
* @default 0
|
|
251
270
|
* @minimum 0
|
|
252
|
-
* @maximum
|
|
271
|
+
* @maximum 432000 (5 days, and cannot exceed retentionSeconds)
|
|
253
272
|
*/
|
|
254
273
|
delaySeconds?: number;
|
|
255
274
|
/**
|
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.
|
|
1643
|
+
init.headers.set("User-Agent", `@vercel/queue/${"0.1.5"}`);
|
|
1641
1644
|
init.headers.set("Vqs-Client-Ts", (/* @__PURE__ */ new Date()).toISOString());
|
|
1642
|
-
const
|
|
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,
|