ruvnet/ruflo · error

Stream error

Error message

Stream error

What it means

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.

Source

Thrown at v3/@claude-flow/testing/src/helpers/test-utils.ts:500

 * Create a mock stream for testing streaming operations
 *
 * @example
 * const stream = createMockStream(['chunk1', 'chunk2', 'chunk3']);
 * for await (const chunk of stream) {
 *   console.log(chunk);
 * }
 */
export function createMockStream<T>(
  chunks: T[],
  options: MockStreamOptions = {}
): AsyncIterable<T> {
  const { delayMs = 0, errorAt, errorMessage = 'Stream error' } = options;

  return {
    async *[Symbol.asyncIterator]() {
      for (let i = 0; i < chunks.length; i++) {
        if (errorAt !== undefined && i === errorAt) {
          throw new Error(errorMessage);
        }

        if (delayMs > 0) {
          await sleep(delayMs);
        }

        yield chunks[i];
      }
    },
  };
}

/**
 * Mock stream options
 */
export interface MockStreamOptions {
  delayMs?: number;
  errorAt?: number;

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Attach an error handler and inspect the underlying stream error cause.
  2. Verify the stream source (file, socket) is valid and readable.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at v3/@claude-flow/testing/src/helpers/test-utils.ts:500 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/9ede311f679e10bc. Report an issue: GitHub.