redis/node-redis · error · Error

All replies must be number arrays of equal length for

Error message

All replies must be number arrays of equal length for ${label} aggregation

What it means

Thrown by the element-wise min/max aggregator when shard replies are arrays of unequal lengths or contain non-number elements. Used for commands whose reply is a fixed-length number array folded element-wise (e.g. WAITAOF returns [numlocal, numreplicas]). Each shard must return an array of the same length so columns align.

Solutions

  1. Ensure all cluster nodes run the same Redis version (WAITAOF reply shape can vary by version)
  2. Check for shard-level errors or degraded nodes returning unexpected replies
  3. Avoid mixing RESP2 and RESP3 across cluster nodes
Defensive patterns

Strategy: try-catch

Type guard

function isElementwiseAggError(err: unknown): boolean {
  return err instanceof Error && err.message.includes('number arrays of equal length');
}

Try / catch

try {
  await cluster.waitAOF(1, 1, 0);
} catch (err) {
  if (err instanceof Error && err.message.includes('number arrays of equal length')) {
    // shard reply shapes differ — check for version mismatch or degraded nodes
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: WAITAOF under all_shards where shards return arrays of different lengths — e.g. one shard returns [1,2] and another returns [1]; a shard returning an array containing non-number elements (strings, nulls) under an unusual type mapping or RESP variant.

Common situations: Heterogeneous cluster where nodes run different Redis versions and WAITAOF reply arity differs; one shard erroring and returning a partial or differently-shaped reply.

Related errors


AI-assisted analysis of redis/node-redis@90fd0652bc (2026-08-11). Data as JSON: /api/errors/a7c90e286e415e7c. Report an issue: GitHub.

Appendix: source

Thrown at packages/client/lib/cluster/request-response-policies/generic-aggregators.ts:93

 * Shared by the array path of `aggregateMin`/`aggregateMax` so element-wise
 * aggregation matches the server's AGG_MIN/AGG_MAX semantics for commands
 * whose reply is an array (e.g. WAITAOF's `[numlocal, numreplicas]`).
 */
const aggregateElementwise = (
  replies: Array<unknown>,
  reduce: (a: number, b: number) => number,
  label: string
): Array<number> => {
  const length = (replies[0] as Array<unknown>).length;
  if (
    !replies.every(
      (reply): reply is number[] =>
        Array.isArray(reply) &&
        reply.length === length &&
        reply.every((value): value is number => typeof value === 'number')
    )
  ) {
    throw new Error(
      `All replies must be number arrays of equal length for ${label} aggregation`
    );
  }

  const result = (replies[0] as number[]).slice();
  for (let r = 1; r < replies.length; r++) {
    const reply = replies[r] as number[];
    for (let i = 0; i < length; i++) {
      result[i] = reduce(result[i], reply[i]);
    }
  }
  return result;
};

/**
 * Aggregates shard replies by taking the minimum value.
 * @remarks
 * Scalar replies (e.g. WAIT, the minimal number of synchronized replicas) fold

View on GitHub (pinned to 90fd0652bc)