@crossdelta/cloudevents 0.7.17 → 0.7.18
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.cjs +6 -2
- package/dist/index.js +6 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2188,7 +2188,7 @@ function cloudEvents(options = {}) {
|
|
|
2188
2188
|
// package.json
|
|
2189
2189
|
var package_default = {
|
|
2190
2190
|
name: "@crossdelta/cloudevents",
|
|
2191
|
-
version: "0.7.
|
|
2191
|
+
version: "0.7.18",
|
|
2192
2192
|
description: "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream & Core"};
|
|
2193
2193
|
|
|
2194
2194
|
// src/plugin.ts
|
|
@@ -2433,6 +2433,7 @@ var SHORT_LIVED_DEFAULTS = {
|
|
|
2433
2433
|
};
|
|
2434
2434
|
var INITIAL_RETRY_DELAY_MS = 1e3;
|
|
2435
2435
|
var MAX_RETRY_DELAY_MS = 3e4;
|
|
2436
|
+
var ESCALATE_AFTER_MS = 5 * 60 * 1e3;
|
|
2436
2437
|
var CONNECTION_REGISTRY_KEY = "__crossdelta_nats_connections__";
|
|
2437
2438
|
var global = globalThis;
|
|
2438
2439
|
var buildConnectOptions = (config, mode) => {
|
|
@@ -2450,11 +2451,14 @@ var getConnectionRegistry = () => {
|
|
|
2450
2451
|
};
|
|
2451
2452
|
var connectWithRetry = async (options, label) => {
|
|
2452
2453
|
let delay = INITIAL_RETRY_DELAY_MS;
|
|
2454
|
+
const startedAt = Date.now();
|
|
2453
2455
|
while (true) {
|
|
2454
2456
|
try {
|
|
2455
2457
|
return await nats.connect(options);
|
|
2456
2458
|
} catch (error) {
|
|
2457
|
-
|
|
2459
|
+
const elapsed = Date.now() - startedAt;
|
|
2460
|
+
const logLevel = elapsed >= ESCALATE_AFTER_MS ? "error" : "info";
|
|
2461
|
+
logger[logLevel](`[${label}] NATS connect failed, retrying in ${delay}ms...`, error);
|
|
2458
2462
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2459
2463
|
delay = Math.min(delay * 2, MAX_RETRY_DELAY_MS);
|
|
2460
2464
|
}
|
package/dist/index.js
CHANGED
|
@@ -2163,7 +2163,7 @@ function cloudEvents(options = {}) {
|
|
|
2163
2163
|
// package.json
|
|
2164
2164
|
var package_default = {
|
|
2165
2165
|
name: "@crossdelta/cloudevents",
|
|
2166
|
-
version: "0.7.
|
|
2166
|
+
version: "0.7.18",
|
|
2167
2167
|
description: "CloudEvents toolkit for TypeScript - Zod validation, handler discovery, NATS JetStream & Core"};
|
|
2168
2168
|
|
|
2169
2169
|
// src/plugin.ts
|
|
@@ -2408,6 +2408,7 @@ var SHORT_LIVED_DEFAULTS = {
|
|
|
2408
2408
|
};
|
|
2409
2409
|
var INITIAL_RETRY_DELAY_MS = 1e3;
|
|
2410
2410
|
var MAX_RETRY_DELAY_MS = 3e4;
|
|
2411
|
+
var ESCALATE_AFTER_MS = 5 * 60 * 1e3;
|
|
2411
2412
|
var CONNECTION_REGISTRY_KEY = "__crossdelta_nats_connections__";
|
|
2412
2413
|
var global = globalThis;
|
|
2413
2414
|
var buildConnectOptions = (config, mode) => {
|
|
@@ -2425,11 +2426,14 @@ var getConnectionRegistry = () => {
|
|
|
2425
2426
|
};
|
|
2426
2427
|
var connectWithRetry = async (options, label) => {
|
|
2427
2428
|
let delay = INITIAL_RETRY_DELAY_MS;
|
|
2429
|
+
const startedAt = Date.now();
|
|
2428
2430
|
while (true) {
|
|
2429
2431
|
try {
|
|
2430
2432
|
return await connect(options);
|
|
2431
2433
|
} catch (error) {
|
|
2432
|
-
|
|
2434
|
+
const elapsed = Date.now() - startedAt;
|
|
2435
|
+
const logLevel = elapsed >= ESCALATE_AFTER_MS ? "error" : "info";
|
|
2436
|
+
logger[logLevel](`[${label}] NATS connect failed, retrying in ${delay}ms...`, error);
|
|
2433
2437
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2434
2438
|
delay = Math.min(delay * 2, MAX_RETRY_DELAY_MS);
|
|
2435
2439
|
}
|
package/package.json
CHANGED