Hmbown/CodeWhale · error · Error

pipeline(): max items per call

Error message

pipeline(): max ${MAX_ITEMS} items per call

What it means

Thrown by the pipeline() JS global exposed by the workflow VM when the caller passes more items than MAX_ITEMS in a single call. The library caps per-call item count to bound execution time and memory inside the sandbox. Split the work into multiple pipeline() calls instead of one oversized call.

Solutions

  1. Chunk the items array into batches of at most MAX_ITEMS and call pipeline() once per batch, aggregating the results.
  2. Filter or paginate the input before calling pipeline() so only needed items are passed.
  3. If the workload legitimately needs a larger cap, check whether MAX_ITEMS is configurable or file an issue to raise the limit rather than working around it in user code.

Example fix

// before
const results = pipeline(allRows, normalize, score);

// after
const CHUNK = 100; // keep <= MAX_ITEMS
const results = [];
for (let i = 0; i < allRows.length; i += CHUNK) {
  results.push(...pipeline(allRows.slice(i, i + CHUNK), normalize, score));
}
Defensive patterns

Strategy: validation

Validate before calling

if (!Array.isArray(items)) throw new TypeError('pipeline(): expected an array of items');
if (items.length > MAX_ITEMS) {
  // chunk beforehand instead of calling
  for (let i = 0; i < items.length; i += MAX_ITEMS) pipeline(items.slice(i, i + MAX_ITEMS), ...stages);
  return;
}

Type guard

function isPipelineInput(v) { return Array.isArray(v) && v.length <= MAX_ITEMS; }

Try / catch

try {
  return pipeline(items, ...stages);
} catch (e) {
  if (String(e.message).includes('max') && e instanceof Error) {
    return items.flatMap((_, i) => pipeline(items.slice(i * MAX_ITEMS, (i + 1) * MAX_ITEMS), ...stages));
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling globalThis.pipeline(items, ...stages) where items is an Array whose length exceeds MAX_ITEMS (crates/workflow-js/src/vm.rs:1619). The array check passes, so the failure is purely about item count.

Common situations: Developers feed a whole dataset, a large file's rows, or an unfiltered query result into pipeline() at once; scripts that worked with small test data break when pointed at production-sized input.

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@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/e5b2f971a813638c. Report an issue: GitHub.

Appendix: source

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

      // 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 73e0f67d83)