{"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/bb5beb56578573910e2ee8f39681edc214c41398/packages/client/lib/client/index.ts#L779-L815","documentation":"#validateOptions rejects `emitInvalidate: true` unless RESP is 3. emitInvalidate wires a push handler that surfaces server 'invalidate' push messages as client 'invalidate' events; those PUSH messages only exist in RESP3. Enabling emitInvalidate on RESP2 would silently emit nothing, so the client fails fast to make the misconfiguration obvious.","triggerScenarios":"`createClient({ RESP: 2, emitInvalidate: true })`; a config object that pins RESP2 and asks for invalidate events.","commonSituations":"Combining an RESP2 compatibility setting with the newer invalidation-events API; copy-paste from a RESP3 example into a RESP2 client.","solutions":["Use RESP3 (the default) when you want emitInvalidate: drop the RESP:2 override.","If you must stay on RESP2, remove emitInvalidate — you cannot receive RESP3 invalidation pushes.","Upgrade the server to a RESP3-capable version."],"exampleFix":"// before\ncreateClient({ RESP: 2, emitInvalidate: true });\n\n// after\ncreateClient({ emitInvalidate: true }); // RESP3 default","handlingStrategy":"validation","validationCode":"function makeClient(opts) {\n  if (opts.emitInvalidate && (opts.RESP ?? 3) !== 3) {\n    throw new TypeError('emitInvalidate requires RESP3');\n  }\n  return createClient(opts);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use RESP3 (the default) when you want emitInvalidate.","Do not combine an RESP2 override with invalidate events."],"tags":["config","resp3","validation"],"analyzedSha":"bb5beb56578573910e2ee8f39681edc214c41398","analyzedAt":"2026-08-03T19:09:15.686Z","schemaVersion":2}