{"record":{"id":"e5b2f971a813638c","repo":"Hmbown/CodeWhale","slug":"pipeline-max-max-items-items-per-call-vm","errorCode":null,"errorMessage":"pipeline(): max ${MAX_ITEMS} items per call","messagePattern":"pipeline\\(\\): max (.+?) items per call","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/workflow-js/src/vm.rs","lineNumber":1619,"sourceCode":"      // event below lets the host status classifier refuse to call such a\n      // run a plain success.\n      if (results.length > 0 && errors.length === results.length) {\n        hostLog(\n          \"parallel(): every slot failed (\" + errors.length + \" of \" + results.length +\n          \"); no work survived this fan-out\"\n        );\n        hostEverySlotFailed(\"parallel\", errors.length, results.length);\n      }\n      return attachSlotErrors(results, errors);\n    });\n  };\n\n  globalThis.pipeline = (items, ...stages) => {\n    if (!Array.isArray(items)) {\n      throw new TypeError(\"pipeline(): expected an array of items\");\n    }\n    if (items.length > MAX_ITEMS) {\n      throw new Error(\"pipeline(): max \" + MAX_ITEMS + \" items per call\");\n    }\n    // Options overload: pipeline(items, { stages: [...], mode: \"fail-fast\" }).\n    let mode = \"settled\";\n    if (\n      stages.length === 1 &&\n      stages[0] !== null &&\n      typeof stages[0] === \"object\" &&\n      Array.isArray(stages[0].stages)\n    ) {\n      mode = slotMode(\"pipeline\", stages[0]);\n      stages = stages[0].stages;\n    }\n    const failFast = mode === \"fail-fast\";\n    const partial = mode === \"partial\";\n    const errors = [];\n    return Promise.all(items.map(async (item, index) => {\n      let value = item;\n      for (const stage of stages) {","sourceCodeStart":1601,"sourceCodeEnd":1637,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/workflow-js/src/vm.rs#L1601-L1637","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Chunk the items array into batches of at most MAX_ITEMS and call pipeline() once per batch, aggregating the results.","Filter or paginate the input before calling pipeline() so only needed items are passed.","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."],"exampleFix":"// before\nconst results = pipeline(allRows, normalize, score);\n\n// after\nconst CHUNK = 100; // keep <= MAX_ITEMS\nconst results = [];\nfor (let i = 0; i < allRows.length; i += CHUNK) {\n  results.push(...pipeline(allRows.slice(i, i + CHUNK), normalize, score));\n}","handlingStrategy":"validation","validationCode":"if (!Array.isArray(items)) throw new TypeError('pipeline(): expected an array of items');\nif (items.length > MAX_ITEMS) {\n  // chunk beforehand instead of calling\n  for (let i = 0; i < items.length; i += MAX_ITEMS) pipeline(items.slice(i, i + MAX_ITEMS), ...stages);\n  return;\n}","typeGuard":"function isPipelineInput(v) { return Array.isArray(v) && v.length <= MAX_ITEMS; }","tryCatchPattern":"try {\n  return pipeline(items, ...stages);\n} catch (e) {\n  if (String(e.message).includes('max') && e instanceof Error) {\n    return items.flatMap((_, i) => pipeline(items.slice(i * MAX_ITEMS, (i + 1) * MAX_ITEMS), ...stages));\n  }\n  throw e;\n}","preventionTips":["Check items.length against the documented MAX_ITEMS before every pipeline() call.","Centralize a chunkedPipeline() helper so no call site passes unbounded arrays.","Filter inputs upstream so only needed items reach pipeline()."],"tags":["javascript","limit","batching","workflow-vm"],"backgroundTag":"value-out-of-range","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}