ruvnet/ruflo · error · Error

formulas and varsArray must have the same length

Error message

formulas and varsArray must have the same length

What it means

cookBatch() received parallel arrays of formulas and per-formula variable objects whose lengths differ, so formulas cannot be paired with their variables. The length equality check runs before any WASM batch cooking; align the two arrays.

Source

Thrown at v3/plugins/gastown-bridge/src/wasm-loader.ts:894

 * @param varsArray - Array of variable objects (one per formula)
 * @returns Array of cooked formulas
 *
 * @example
 * ```typescript
 * const cooked = await cookBatch(
 *   [formula1, formula2],
 *   [{ name: 'a' }, { name: 'b' }]
 * );
 * ```
 */
export async function cookBatch(
  formulas: Formula[],
  varsArray: Record<string, string>[]
): Promise<Formula[]> {
  const startTime = performance.now();

  if (formulas.length !== varsArray.length) {
    throw new Error('formulas and varsArray must have the same length');
  }

  const wasmModule = await loadFormulaWasm();

  if (wasmModule) {
    try {
      const resultJson = wasmModule.cook_batch(
        JSON.stringify(formulas),
        JSON.stringify(varsArray)
      );
      const result = JSON.parse(resultJson) as Formula[];
      recordTiming('cookBatch', startTime, true);
      return result;
    } catch (error) {
      console.warn('[WASM Loader] cook_batch failed, using fallback:', error);
    }
  }

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Ensure both inputs have identical lengths before the operation; pad or truncate as appropriate for the domain.
  2. Validate lengths at the call site and fail fast with both lengths in the message.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at v3/plugins/gastown-bridge/src/wasm-loader.ts:894 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/3e9b5bca06d5cb15. Report an issue: GitHub.