{"record":{"id":"9ede311f679e10bc","repo":"ruvnet/ruflo","slug":"stream-error","errorCode":null,"errorMessage":"Stream error","messagePattern":"Stream error","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/testing/src/helpers/test-utils.ts","lineNumber":500,"sourceCode":" * Create a mock stream for testing streaming operations\n *\n * @example\n * const stream = createMockStream(['chunk1', 'chunk2', 'chunk3']);\n * for await (const chunk of stream) {\n *   console.log(chunk);\n * }\n */\nexport function createMockStream<T>(\n  chunks: T[],\n  options: MockStreamOptions = {}\n): AsyncIterable<T> {\n  const { delayMs = 0, errorAt, errorMessage = 'Stream error' } = options;\n\n  return {\n    async *[Symbol.asyncIterator]() {\n      for (let i = 0; i < chunks.length; i++) {\n        if (errorAt !== undefined && i === errorAt) {\n          throw new Error(errorMessage);\n        }\n\n        if (delayMs > 0) {\n          await sleep(delayMs);\n        }\n\n        yield chunks[i];\n      }\n    },\n  };\n}\n\n/**\n * Mock stream options\n */\nexport interface MockStreamOptions {\n  delayMs?: number;\n  errorAt?: number;","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/testing/src/helpers/test-utils.ts#L482-L518","documentation":"createMockStream's async iterator reached the configured errorAt chunk index and deliberately throws errorMessage (default 'Stream error'). This is intentional simulated mid-stream failure for testing consumer error handling — not a bug in the helper.","triggerScenarios":"Thrown at v3/@claude-flow/testing/src/helpers/test-utils.ts:500 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Attach an error handler and inspect the underlying stream error cause.","Verify the stream source (file, socket) is valid and readable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}