{"record":{"id":"b69805db7209d571","repo":"redis/node-redis","slug":"emitinvalidate-is-only-supported-with-resp3","errorCode":null,"errorMessage":"emitInvalidate is only supported with RESP3","messagePattern":"emitInvalidate is only supported with RESP3","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/client/lib/client/index.ts","lineNumber":797,"sourceCode":"        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 = {\n        type: 'async-credentials-provider',\n        credentials: async () => ({\n          username: options.username,","sourceCodeStart":779,"sourceCodeEnd":815,"githubUrl":"https://github.com/redis/node-redis/blob/90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58/packages/client/lib/client/index.ts#L779-L815","documentation":"emitInvalidate surfaces RESP3 push/invalidate events to user code via the 'invalidate' emitter. It therefore requires RESP3; with any other RESP version it is rejected in #validateOptions.","triggerScenarios":"createClient({ emitInvalidate: true, RESP: 2 }) or omitting RESP while the negotiated version falls below 3.","commonSituations":"Wanting raw invalidation events on a RESP2 connection; legacy config; older redis server that cannot do RESP3.","solutions":["Set RESP: 3 and connect to a redis >= 6 server.","Or remove emitInvalidate and consume invalidations through the clientSideCache mechanism instead."],"exampleFix":"// before\ncreateClient({ emitInvalidate: true });\n\n// after\ncreateClient({ emitInvalidate: true, RESP: 3 });","handlingStrategy":"validation","validationCode":"function validateInvalidateOptions(options) {\n  const resp = options?.RESP ?? 3;\n  if (options?.emitInvalidate && resp !== 3) {\n    throw new Error('emitInvalidate requires RESP: 3');\n  }\n  return options;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set RESP: 3 when you need raw invalidate events.","If you cannot move to RESP3, use clientSideCache instead (which still requires RESP3) or skip invalidation.","Validate options at app startup."],"tags":["config","resp3","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"}