{"record":{"id":"e235c13b1bb109ce","repo":"redis/node-redis","slug":"emitinvalidate-is-not-supported-or-necessary-whe","errorCode":null,"errorMessage":"emitInvalidate is not supported (or necessary) when clientSideCache is enabled","messagePattern":"emitInvalidate is not supported \\(or necessary\\) when clientSideCache is enabled","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/client/lib/client/index.ts","lineNumber":800,"sourceCode":"          }\n        } else {\n          this.emit('invalidate', null);\n        }\n        return true\n      });\n    }\n  }\n\n  #validateOptions(options?: RedisClientOptions<M, F, S, RESP, TYPE_MAPPING>) {\n    const resp = options?.RESP ?? DEFAULT_RESP;\n    if (options?.clientSideCache && resp !== 3) {\n      throw new Error('Client Side Caching is only supported with RESP3');\n    }\n    if (options?.emitInvalidate && resp !== 3) {\n      throw new Error('emitInvalidate is only supported with RESP3');\n    }\n    if (options?.clientSideCache && options?.emitInvalidate) {\n      throw new Error('emitInvalidate is not supported (or necessary) when clientSideCache is enabled');\n    }\n    if (options?.maintNotifications && options?.maintNotifications !== 'disabled' && resp !== 3) {\n      throw new Error('Graceful Maintenance is only supported with RESP3');\n    }\n  }\n\n  #initiateOptions(options: RedisClientOptions<M, F, S, RESP, TYPE_MAPPING> = {}): RedisClientOptions<M, F, S, RESP, TYPE_MAPPING> {\n\n    // Convert username/password to credentialsProvider if no credentialsProvider is already in place\n    if (!options.credentialsProvider && (options.username || options.password)) {\n\n      options.credentialsProvider = {\n        type: 'async-credentials-provider',\n        credentials: async () => ({\n          username: options.username,\n          password: options.password\n        })\n      };","sourceCodeStart":782,"sourceCodeEnd":818,"githubUrl":"https://github.com/redis/node-redis/blob/90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58/packages/client/lib/client/index.ts#L782-L818","documentation":"clientSideCache already consumes invalidation push messages internally; enabling emitInvalidate at the same time would be redundant and ambiguous (two consumers for the same events). The two options are mutually exclusive and #validateOptions rejects the combination.","triggerScenarios":"createClient({ clientSideCache: myCache, emitInvalidate: true }).","commonSituations":"Copy-pasting both options when migrating from a raw-invalidation setup to the cache abstraction; experimenting and forgetting to remove one.","solutions":["Use clientSideCache and let it handle invalidations, removing emitInvalidate.","Or use emitInvalidate alone for custom handling and drop clientSideCache."],"exampleFix":"// before\ncreateClient({ clientSideCache: myCache, emitInvalidate: true });\n\n// after\ncreateClient({ clientSideCache: myCache });","handlingStrategy":"validation","validationCode":"function validateCscVsEmit(options) {\n  if (options?.clientSideCache && options?.emitInvalidate) {\n    throw new Error('Enable only one of clientSideCache or emitInvalidate, not both');\n  }\n  return options;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat clientSideCache and emitInvalidate as mutually exclusive.","When migrating from raw invalidation to the cache abstraction, remove emitInvalidate.","Validate the option combination at startup."],"tags":["config","client-side-caching","validation"],"backgroundTag":null,"analyzedSha":"90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58","analyzedAt":"2026-08-11T15:37:21.243Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}