@frontmcp/plugin-cache 1.8.6 → 1.8.7

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/esm/index.mjs CHANGED
@@ -296,7 +296,6 @@ import {
296
296
  } from "@frontmcp/sdk";
297
297
 
298
298
  // libs/utils/dist/esm/index.mjs
299
- import { createRequire as __frontmcpCreateRequire } from "module";
300
299
  import { z } from "@frontmcp/lazy-zod";
301
300
  var import_event_emitter = __toESM(require_node_event_emitter(), 1);
302
301
  import { z as z2 } from "@frontmcp/lazy-zod";
@@ -309,7 +308,8 @@ import { randomBytes as nobleRandomBytes } from "@noble/hashes/utils.js";
309
308
  import { gcm } from "@noble/ciphers/aes.js";
310
309
  import { analyzeForReDoS, REDOS_THRESHOLDS } from "@enclave-vm/ast";
311
310
  import { z as z3 } from "@frontmcp/lazy-zod";
312
- var require2 = __frontmcpCreateRequire(import.meta.url || "file:///");
311
+ var __frontmcpModule = typeof process !== "undefined" && typeof process.getBuiltinModule === "function" ? process.getBuiltinModule("module") : void 0;
312
+ var require2 = __frontmcpModule ? __frontmcpModule.createRequire(import.meta.url || "file:///") : void 0;
313
313
  var __defProp2 = Object.defineProperty;
314
314
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
315
315
  var __require2 = /* @__PURE__ */ ((x) => typeof require2 !== "undefined" ? require2 : typeof Proxy !== "undefined" ? new Proxy(x, {
@@ -2545,6 +2545,39 @@ var init_crypto = __esm({
2545
2545
  HKDF_SHA256_MAX_LENGTH = 255 * 32;
2546
2546
  }
2547
2547
  });
2548
+ function attachRedisErrorListener(client, options = {}) {
2549
+ const label = options.label ?? "redis";
2550
+ const intervalMs = options.intervalMs ?? DEFAULT_REDIS_ERROR_LOG_INTERVAL_MS;
2551
+ let lastLoggedAt = 0;
2552
+ let suppressed = 0;
2553
+ const listener = (error) => {
2554
+ const now = Date.now();
2555
+ if (lastLoggedAt !== 0 && now - lastLoggedAt < intervalMs) {
2556
+ suppressed++;
2557
+ return;
2558
+ }
2559
+ const extra = suppressed > 0 ? ` (${suppressed} similar error(s) suppressed)` : "";
2560
+ suppressed = 0;
2561
+ lastLoggedAt = now;
2562
+ const message = `[${label}] Redis connection error: ${error?.message ?? String(error)}${extra}`;
2563
+ if (options.logger) {
2564
+ options.logger.warn(message);
2565
+ } else {
2566
+ console.warn(message);
2567
+ }
2568
+ };
2569
+ client.on("error", listener);
2570
+ return () => {
2571
+ client.removeListener("error", listener);
2572
+ };
2573
+ }
2574
+ var DEFAULT_REDIS_ERROR_LOG_INTERVAL_MS;
2575
+ var init_redis_error_listener = __esm({
2576
+ "libs/utils/src/storage/redis-error-listener.ts"() {
2577
+ "use strict";
2578
+ DEFAULT_REDIS_ERROR_LOG_INTERVAL_MS = 3e4;
2579
+ }
2580
+ });
2548
2581
  var init_utils = __esm({
2549
2582
  "libs/utils/src/storage/utils/index.ts"() {
2550
2583
  "use strict";
@@ -2553,7 +2586,8 @@ var init_utils = __esm({
2553
2586
  });
2554
2587
  var redis_exports = {};
2555
2588
  __export(redis_exports, {
2556
- RedisStorageAdapter: () => RedisStorageAdapter
2589
+ RedisStorageAdapter: () => RedisStorageAdapter,
2590
+ createRedisClient: () => createRedisClient
2557
2591
  });
2558
2592
  function getRedisClass() {
2559
2593
  try {
@@ -2571,11 +2605,26 @@ function getRedisClass() {
2571
2605
  });
2572
2606
  }
2573
2607
  }
2608
+ function createRedisClient(options) {
2609
+ const RedisClass = getRedisClass();
2610
+ const baseOptions = { lazyConnect: false, maxRetriesPerRequest: 3 };
2611
+ const client = options.url ? new RedisClass(options.url, baseOptions) : new RedisClass({
2612
+ ...baseOptions,
2613
+ host: options.host ?? "localhost",
2614
+ port: options.port ?? 6379,
2615
+ password: options.password,
2616
+ db: options.db ?? 0,
2617
+ tls: options.tls ? {} : void 0
2618
+ });
2619
+ attachRedisErrorListener(client, { label: options.label ?? "redis", logger: options.logger });
2620
+ return client;
2621
+ }
2574
2622
  var RedisStorageAdapter;
2575
2623
  var init_redis = __esm({
2576
2624
  "libs/utils/src/storage/adapters/redis.ts"() {
2577
2625
  "use strict";
2578
2626
  init_errors();
2627
+ init_redis_error_listener();
2579
2628
  init_utils();
2580
2629
  init_base();
2581
2630
  RedisStorageAdapter = class extends BaseStorageAdapter {
@@ -2584,6 +2633,7 @@ var init_redis = __esm({
2584
2633
  subscriber;
2585
2634
  options;
2586
2635
  ownsClient;
2636
+ detachErrorListener;
2587
2637
  connecting;
2588
2638
  keyPrefix;
2589
2639
  subscriptionHandlers = /* @__PURE__ */ new Map();
@@ -2640,7 +2690,10 @@ var init_redis = __esm({
2640
2690
  await client.ping();
2641
2691
  this.client = client;
2642
2692
  this.connected = true;
2643
- if (this.ownsClient) client.removeListener("error", recordSocketError);
2693
+ if (this.ownsClient) {
2694
+ client.removeListener("error", recordSocketError);
2695
+ this.detachErrorListener = attachRedisErrorListener(client, { label: "RedisStorage" });
2696
+ }
2644
2697
  } catch (e) {
2645
2698
  if (this.ownsClient && client) {
2646
2699
  try {
@@ -2661,6 +2714,8 @@ var init_redis = __esm({
2661
2714
  if (this.ownsClient && this.client) {
2662
2715
  await this.client.quit();
2663
2716
  }
2717
+ this.detachErrorListener?.();
2718
+ this.detachErrorListener = void 0;
2664
2719
  this.client = void 0;
2665
2720
  this.connected = false;
2666
2721
  this.subscriptionHandlers.clear();
@@ -2888,6 +2943,7 @@ var init_redis = __esm({
2888
2943
  } else {
2889
2944
  throw new StorageConfigError("redis", "Cannot create subscriber without url, config, or client");
2890
2945
  }
2946
+ attachRedisErrorListener(subscriber, { label: "RedisStorage:subscriber" });
2891
2947
  subscriber.on("message", (channel, message) => {
2892
2948
  const handlers = this.subscriptionHandlers.get(channel);
2893
2949
  if (handlers) {
@@ -3670,6 +3726,7 @@ var entryAvailabilitySchema = z3.object({
3670
3726
  }).strict();
3671
3727
  init_errors();
3672
3728
  init_memory();
3729
+ init_redis_error_listener();
3673
3730
  init_errors();
3674
3731
  init_crypto();
3675
3732
  init_errors();
package/esm/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontmcp/plugin-cache",
3
- "version": "1.8.6",
3
+ "version": "1.8.7",
4
4
  "description": "Cache plugin for FrontMCP - Redis, Vercel KV, and in-memory caching with automatic tool result caching",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "license": "Apache-2.0",
@@ -48,8 +48,8 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "@frontmcp/sdk": "1.8.6",
52
- "@frontmcp/utils": "1.8.6",
51
+ "@frontmcp/sdk": "1.8.7",
52
+ "@frontmcp/utils": "1.8.7",
53
53
  "ioredis": "^5.8.0"
54
54
  },
55
55
  "peerDependencies": {
package/index.js CHANGED
@@ -296,7 +296,6 @@ module.exports = __toCommonJS(index_exports);
296
296
  var import_sdk4 = require("@frontmcp/sdk");
297
297
 
298
298
  // libs/utils/dist/esm/index.mjs
299
- var import_module = require("module");
300
299
  var import_lazy_zod = require("@frontmcp/lazy-zod");
301
300
  var import_lazy_zod2 = require("@frontmcp/lazy-zod");
302
301
  var import_event_emitter = __toESM(require_node_event_emitter(), 1);
@@ -310,7 +309,8 @@ var import_crypto_provider = __toESM(require_node(), 1);
310
309
  var import_ast = require("@enclave-vm/ast");
311
310
  var import_lazy_zod3 = require("@frontmcp/lazy-zod");
312
311
  var import_meta = {};
313
- var require2 = (0, import_module.createRequire)(import_meta.url || "file:///");
312
+ var __frontmcpModule = typeof process !== "undefined" && typeof process.getBuiltinModule === "function" ? process.getBuiltinModule("module") : void 0;
313
+ var require2 = __frontmcpModule ? __frontmcpModule.createRequire(import_meta.url || "file:///") : void 0;
314
314
  var __defProp2 = Object.defineProperty;
315
315
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
316
316
  var __require = /* @__PURE__ */ ((x) => typeof require2 !== "undefined" ? require2 : typeof Proxy !== "undefined" ? new Proxy(x, {
@@ -2546,6 +2546,39 @@ var init_crypto = __esm({
2546
2546
  HKDF_SHA256_MAX_LENGTH = 255 * 32;
2547
2547
  }
2548
2548
  });
2549
+ function attachRedisErrorListener(client, options = {}) {
2550
+ const label = options.label ?? "redis";
2551
+ const intervalMs = options.intervalMs ?? DEFAULT_REDIS_ERROR_LOG_INTERVAL_MS;
2552
+ let lastLoggedAt = 0;
2553
+ let suppressed = 0;
2554
+ const listener = (error) => {
2555
+ const now = Date.now();
2556
+ if (lastLoggedAt !== 0 && now - lastLoggedAt < intervalMs) {
2557
+ suppressed++;
2558
+ return;
2559
+ }
2560
+ const extra = suppressed > 0 ? ` (${suppressed} similar error(s) suppressed)` : "";
2561
+ suppressed = 0;
2562
+ lastLoggedAt = now;
2563
+ const message = `[${label}] Redis connection error: ${error?.message ?? String(error)}${extra}`;
2564
+ if (options.logger) {
2565
+ options.logger.warn(message);
2566
+ } else {
2567
+ console.warn(message);
2568
+ }
2569
+ };
2570
+ client.on("error", listener);
2571
+ return () => {
2572
+ client.removeListener("error", listener);
2573
+ };
2574
+ }
2575
+ var DEFAULT_REDIS_ERROR_LOG_INTERVAL_MS;
2576
+ var init_redis_error_listener = __esm({
2577
+ "libs/utils/src/storage/redis-error-listener.ts"() {
2578
+ "use strict";
2579
+ DEFAULT_REDIS_ERROR_LOG_INTERVAL_MS = 3e4;
2580
+ }
2581
+ });
2549
2582
  var init_utils = __esm({
2550
2583
  "libs/utils/src/storage/utils/index.ts"() {
2551
2584
  "use strict";
@@ -2554,7 +2587,8 @@ var init_utils = __esm({
2554
2587
  });
2555
2588
  var redis_exports = {};
2556
2589
  __export2(redis_exports, {
2557
- RedisStorageAdapter: () => RedisStorageAdapter
2590
+ RedisStorageAdapter: () => RedisStorageAdapter,
2591
+ createRedisClient: () => createRedisClient
2558
2592
  });
2559
2593
  function getRedisClass() {
2560
2594
  try {
@@ -2572,11 +2606,26 @@ function getRedisClass() {
2572
2606
  });
2573
2607
  }
2574
2608
  }
2609
+ function createRedisClient(options) {
2610
+ const RedisClass = getRedisClass();
2611
+ const baseOptions = { lazyConnect: false, maxRetriesPerRequest: 3 };
2612
+ const client = options.url ? new RedisClass(options.url, baseOptions) : new RedisClass({
2613
+ ...baseOptions,
2614
+ host: options.host ?? "localhost",
2615
+ port: options.port ?? 6379,
2616
+ password: options.password,
2617
+ db: options.db ?? 0,
2618
+ tls: options.tls ? {} : void 0
2619
+ });
2620
+ attachRedisErrorListener(client, { label: options.label ?? "redis", logger: options.logger });
2621
+ return client;
2622
+ }
2575
2623
  var RedisStorageAdapter;
2576
2624
  var init_redis = __esm({
2577
2625
  "libs/utils/src/storage/adapters/redis.ts"() {
2578
2626
  "use strict";
2579
2627
  init_errors();
2628
+ init_redis_error_listener();
2580
2629
  init_utils();
2581
2630
  init_base();
2582
2631
  RedisStorageAdapter = class extends BaseStorageAdapter {
@@ -2585,6 +2634,7 @@ var init_redis = __esm({
2585
2634
  subscriber;
2586
2635
  options;
2587
2636
  ownsClient;
2637
+ detachErrorListener;
2588
2638
  connecting;
2589
2639
  keyPrefix;
2590
2640
  subscriptionHandlers = /* @__PURE__ */ new Map();
@@ -2641,7 +2691,10 @@ var init_redis = __esm({
2641
2691
  await client.ping();
2642
2692
  this.client = client;
2643
2693
  this.connected = true;
2644
- if (this.ownsClient) client.removeListener("error", recordSocketError);
2694
+ if (this.ownsClient) {
2695
+ client.removeListener("error", recordSocketError);
2696
+ this.detachErrorListener = attachRedisErrorListener(client, { label: "RedisStorage" });
2697
+ }
2645
2698
  } catch (e) {
2646
2699
  if (this.ownsClient && client) {
2647
2700
  try {
@@ -2662,6 +2715,8 @@ var init_redis = __esm({
2662
2715
  if (this.ownsClient && this.client) {
2663
2716
  await this.client.quit();
2664
2717
  }
2718
+ this.detachErrorListener?.();
2719
+ this.detachErrorListener = void 0;
2665
2720
  this.client = void 0;
2666
2721
  this.connected = false;
2667
2722
  this.subscriptionHandlers.clear();
@@ -2889,6 +2944,7 @@ var init_redis = __esm({
2889
2944
  } else {
2890
2945
  throw new StorageConfigError("redis", "Cannot create subscriber without url, config, or client");
2891
2946
  }
2947
+ attachRedisErrorListener(subscriber, { label: "RedisStorage:subscriber" });
2892
2948
  subscriber.on("message", (channel, message) => {
2893
2949
  const handlers = this.subscriptionHandlers.get(channel);
2894
2950
  if (handlers) {
@@ -3671,6 +3727,7 @@ var entryAvailabilitySchema = import_lazy_zod3.z.object({
3671
3727
  }).strict();
3672
3728
  init_errors();
3673
3729
  init_memory();
3730
+ init_redis_error_listener();
3674
3731
  init_errors();
3675
3732
  init_crypto();
3676
3733
  init_errors();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontmcp/plugin-cache",
3
- "version": "1.8.6",
3
+ "version": "1.8.7",
4
4
  "description": "Cache plugin for FrontMCP - Redis, Vercel KV, and in-memory caching with automatic tool result caching",
5
5
  "author": "AgentFront <info@agentfront.dev>",
6
6
  "license": "Apache-2.0",
@@ -48,8 +48,8 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "@frontmcp/sdk": "1.8.6",
52
- "@frontmcp/utils": "1.8.6",
51
+ "@frontmcp/sdk": "1.8.7",
52
+ "@frontmcp/utils": "1.8.7",
53
53
  "ioredis": "^5.8.0"
54
54
  },
55
55
  "peerDependencies": {