Hmbown/CodeWhale · error · Error

pipeline(): max " + MAX_ITEMS + " items per call

Error message

pipeline(): max " + MAX_ITEMS + " items per call

What it means

The `globalThis.pipeline()` JS binding enforces a hard cap of MAX_ITEMS items per call to bound memory and execution time inside the VM. Calling it with an array longer than that limit throws a plain Error before any stage runs. It is an input-size guard, not a failure of the pipeline itself.

Solutions

  1. Check `items.length` against MAX_ITEMS before calling and chunk the array into batches under the limit.
  2. Run multiple `pipeline()` calls over slices and merge the results outside the VM.
  3. Filter the input before pipelining so only items that actually need processing are passed.

Example fix

// before
const results = globalThis.pipeline(allItems, stage1, stage2);
// after
const results = [];
for (let i = 0; i < allItems.length; i += 100) {
  results.push(...globalThis.pipeline(allItems.slice(i, i + 100), stage1, stage2));
}
Defensive patterns

Strategy: validation

Validate before calling

if (!Array.isArray(items) || items.length > MAX_ITEMS) {
  // chunk or reject before calling pipeline
}

Type guard

function canPipeline(items, maxItems) {
  return Array.isArray(items) && items.length <= maxItems;
}

Prevention

When it happens

Trigger: Calling `globalThis.pipeline(items, ...stages)` where `items` is a valid Array whose `.length > MAX_ITEMS` (checked in the JS glue before stage evaluation).

Common situations: Bulk-processing a large result set or file listing through the pipeline in one call; a caller that batches all work instead of chunking; a version bump lowered MAX_ITEMS and old scripts now exceed the limit.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/98bd230487eab6d8. Report an issue: GitHub.

Appendix: source

Thrown at crates/workflow-js/src/vm.rs:1452

      // event below lets the host status classifier refuse to call such a
      // run a plain success.
      if (results.length > 0 && errors.length === results.length) {
        hostLog(
          "parallel(): every slot failed (" + errors.length + " of " + results.length +
          "); no work survived this fan-out"
        );
        hostEverySlotFailed("parallel", errors.length, results.length);
      }
      return attachSlotErrors(results, errors);
    });
  };

  globalThis.pipeline = (items, ...stages) => {
    if (!Array.isArray(items)) {
      throw new TypeError("pipeline(): expected an array of items");
    }
    if (items.length > MAX_ITEMS) {
      throw new Error("pipeline(): max " + MAX_ITEMS + " items per call");
    }
    // Options overload: pipeline(items, { stages: [...], mode: "fail-fast" }).
    let mode = "settled";
    if (
      stages.length === 1 &&
      stages[0] !== null &&
      typeof stages[0] === "object" &&
      Array.isArray(stages[0].stages)
    ) {
      mode = slotMode("pipeline", stages[0]);
      stages = stages[0].stages;
    }
    const failFast = mode === "fail-fast";
    const partial = mode === "partial";
    const errors = [];
    return Promise.all(items.map(async (item, index) => {
      let value = item;
      for (const stage of stages) {

View on GitHub (pinned to 433685b202)