{"id":"ce80bd86a93d1672","repo":"redis/node-redis","slug":"client-side-caching-is-only-supported-with-resp3","errorCode":null,"errorMessage":"Client Side Caching is only supported with RESP3","messagePattern":"Client Side Caching is only supported with RESP3","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/client/lib/client/index.ts","lineNumber":794,"sourceCode":"      this.#queue.addPushHandler((push: Array<any>): boolean => {\n        if (push[0].toString() !== 'invalidate') return false;\n\n        if (push[1] !== null) {\n          for (const key of push[1]) {\n            this.emit('invalidate', key);\n          }\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 = {","sourceCodeStart":776,"sourceCodeEnd":812,"githubUrl":"https://github.com/redis/node-redis/blob/bb5beb56578573910e2ee8f39681edc214c41398/packages/client/lib/client/index.ts#L776-L812","documentation":"#validateOptions runs during client construction and enforces that the client-side cache (options.clientSideCache) is only enabled when the RESP version is 3. Client-side caching relies on RESP3 PUSH messages (invalidation notifications) sent by the server, which do not exist in RESP2; enabling the cache on RESP2 would silently never receive invalidations. The default RESP version is 3, so this fires only when RESP is explicitly set to 2 alongside clientSideCache.","triggerScenarios":"`createClient({ RESP: 2, clientSideCache: new BasicClientSideCache() })`; a base config that sets isolationLevel/RESP to 2 combined with a cache config that turns the cache on.","commonSituations":"Forcing RESP2 for compatibility with an old server while also wanting client-side caching; layered config where one layer pins RESP and another enables the cache; migrating to client-side caching on a server that does not support RESP3.","solutions":["Remove the RESP:2 override (or set RESP:3) so the client negotiates RESP3 and the cache works.","Upgrade the Redis server to >= 6.0 with RESP3 support if needed.","If RESP2 is mandatory, do not enable clientSideCache (it cannot function without RESP3 invalidations)."],"exampleFix":"// before\ncreateClient({ RESP: 2, clientSideCache: new BasicClientSideCache() });\n\n// after\ncreateClient({ clientSideCache: new BasicClientSideCache() }); // RESP3 is the default","handlingStrategy":"validation","validationCode":"function makeClient(opts) {\n  if (opts.clientSideCache && (opts.RESP ?? 3) !== 3) {\n    throw new TypeError('clientSideCache requires RESP3');\n  }\n  return createClient(opts);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not pin RESP:2 when enabling clientSideCache.","Verify the server supports RESP3 (Redis >= 6.0).","Use RESP3 (the default) for client-side caching."],"tags":["config","resp3","client-side-caching","validation"],"analyzedSha":"bb5beb56578573910e2ee8f39681edc214c41398","analyzedAt":"2026-08-03T19:09:15.686Z","schemaVersion":2}