{"record":{"id":"98bd230487eab6d8","repo":"Hmbown/CodeWhale","slug":"pipeline-max-max-items-items-per-call","errorCode":null,"errorMessage":"pipeline(): max \" + MAX_ITEMS + \" items per call","messagePattern":"pipeline\\(\\): max \" \\+ MAX_ITEMS \\+ \" items per call","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/workflow-js/src/vm.rs","lineNumber":1452,"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":1434,"sourceCodeEnd":1470,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/workflow-js/src/vm.rs#L1434-L1470","documentation":"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.","triggerScenarios":"Calling `globalThis.pipeline(items, ...stages)` where `items` is a valid Array whose `.length > MAX_ITEMS` (checked in the JS glue before stage evaluation).","commonSituations":"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.","solutions":["Check `items.length` against MAX_ITEMS before calling and chunk the array into batches under the limit.","Run multiple `pipeline()` calls over slices and merge the results outside the VM.","Filter the input before pipelining so only items that actually need processing are passed."],"exampleFix":"// before\nconst results = globalThis.pipeline(allItems, stage1, stage2);\n// after\nconst results = [];\nfor (let i = 0; i < allItems.length; i += 100) {\n  results.push(...globalThis.pipeline(allItems.slice(i, i + 100), stage1, stage2));\n}","handlingStrategy":"validation","validationCode":"if (!Array.isArray(items) || items.length > MAX_ITEMS) {\n  // chunk or reject before calling pipeline\n}","typeGuard":"function canPipeline(items, maxItems) {\n  return Array.isArray(items) && items.length <= maxItems;\n}","tryCatchPattern":null,"preventionTips":["Always chunk large arrays before passing them to pipeline().","Define a shared batch-size constant aligned with MAX_ITEMS.","Filter inputs down to items that need processing before batching."],"tags":["javascript","input-validation","limit-exceeded","pipeline"],"backgroundTag":"value-out-of-range","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}