{"record":{"id":"cd9e30c81091ebe2","repo":"redis/node-redis","slug":"errorindexes-length-commands-failed-see-repli","errorCode":null,"errorMessage":"${errorIndexes.length} commands failed, see .replies and .errorIndexes for more information","messagePattern":"(.+?) commands failed, see \\.replies and \\.errorIndexes for more information","errorType":"exception","errorClass":"MultiErrorReply","httpStatus":null,"severity":"error","filePath":"packages/client/lib/multi-command.ts","lineNumber":74,"sourceCode":"\n    redisArgs.push(...args);\n\n    this.addCommand(redisArgs, transformReply);\n  }\n  \n  transformReplies(rawReplies: Array<unknown>): Array<unknown> {\n    const errorIndexes: Array<number> = [],\n      replies = rawReplies.map((reply, i) => {\n        if (reply instanceof ErrorReply) {\n          errorIndexes.push(i);\n          return reply;\n        }\n\n        const { transformReply, args } = this.queue[i];\n        return transformReply ? transformReply(reply, args.preserve, this.typeMapping) : reply;\n      });\n\n    if (errorIndexes.length) throw new MultiErrorReply(replies, errorIndexes);\n    return replies;\n  }\n}\n","sourceCodeStart":56,"sourceCodeEnd":78,"githubUrl":"https://github.com/redis/node-redis/blob/90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58/packages/client/lib/multi-command.ts#L56-L78","documentation":"After executing a MULTI/EXEC transaction, one or more queued commands returned an ErrorReply from the server. The client collects all per-command errors and throws a MultiErrorReply containing the full replies array and the indexes of failed commands for inspection.","triggerScenarios":"A transaction where individual commands fail at EXEC time — WRONGTYPE on a key, arity errors, or server-side constraint violations. The transaction executes atomically but some commands within it error.","commonSituations":"Transaction contains a command operating on a key with the wrong data type; server OOM during execution; a queued command with invalid arguments that passes QUEUED but fails at EXEC; permission errors on specific commands.","solutions":["Catch MultiErrorReply and iterate .errorIndexes to find which commands failed","Inspect .replies[i] for the specific ErrorReply message of each failed command","Use the .errors() generator to iterate only the error replies","Validate key types and command preconditions before queuing commands in the transaction"],"exampleFix":"// before\nconst replies = await multi.exec();\n\n// after\ntry {\n  const replies = await multi.exec();\n} catch (e) {\n  if (e instanceof MultiErrorReply) {\n    for (const [idx, err] of e.errors()) {\n      console.error(`Command ${idx} failed:`, err.message);\n    }\n  } else {\n    throw e;\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"import { MultiErrorReply } from 'redis';\n\nfunction isMultiErrorReply(e: unknown): e is MultiErrorReply {\n  return e instanceof MultiErrorReply;\n}","tryCatchPattern":"try {\n  const replies = await multi.exec();\n} catch (e) {\n  if (e instanceof MultiErrorReply) {\n    for (const err of e.errors()) {\n      console.error('Transaction command failed:', err.message);\n    }\n    // Optionally inspect e.replies for successful command results\n  } else {\n    throw e;\n  }\n}","preventionTips":["Validate key types and command preconditions before queuing commands in MULTI","Use WATCH for optimistic locking to detect conflicts before EXEC","Inspect MultiErrorReply.errorIndexes to identify which specific commands failed","Test transactions with realistic data to catch type-mismatch errors early"],"tags":["transaction","multi","error-handling"],"backgroundTag":null,"analyzedSha":"90fd0652bc3f2a0a1b2f79fa9096b02a86b0ac58","analyzedAt":"2026-08-11T15:37:21.243Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}