@digilogiclabs/platform-core 1.28.0 → 1.28.1

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.mjs CHANGED
@@ -19526,11 +19526,24 @@ async function checkRateLimit(operation, identifier, rule, options = {}) {
19526
19526
  retryAfterSeconds: 0
19527
19527
  };
19528
19528
  } catch (error) {
19529
- options.logger?.error("Rate limit check failed, allowing request", {
19530
- error: error instanceof Error ? error.message : String(error),
19531
- operation,
19532
- identifier
19533
- });
19529
+ options.logger?.error(
19530
+ rule.failClosed ? "Rate limit check failed, denying request (fail-closed rule)" : "Rate limit check failed, allowing request",
19531
+ {
19532
+ error: error instanceof Error ? error.message : String(error),
19533
+ operation,
19534
+ identifier
19535
+ }
19536
+ );
19537
+ if (rule.failClosed) {
19538
+ return {
19539
+ allowed: false,
19540
+ remaining: 0,
19541
+ resetAt,
19542
+ current: 0,
19543
+ limit,
19544
+ retryAfterSeconds: 30
19545
+ };
19546
+ }
19534
19547
  return {
19535
19548
  allowed: true,
19536
19549
  remaining: limit,
@@ -33283,9 +33296,12 @@ function createRedisClient(options) {
33283
33296
  const client = new Redis(url, {
33284
33297
  keyPrefix,
33285
33298
  maxRetriesPerRequest: maxRetries,
33299
+ // Never give up reconnecting. Returning null here ends the connection
33300
+ // for good, and a long-lived singleton (rate limiting, caching) would
33301
+ // then stay broken until the process restarts. maxRetriesPerRequest
33302
+ // still makes individual commands fail fast while disconnected.
33286
33303
  retryStrategy(times) {
33287
- if (times > maxRetries) return null;
33288
- return Math.min(times * 200, 2e3);
33304
+ return Math.min(times * 200, 5e3);
33289
33305
  },
33290
33306
  lazyConnect
33291
33307
  });