react/react · error · Error

Values cannot be passed to next() of AsyncIterables passed t

Error message

Values cannot be passed to next() of AsyncIterables passed to Client Components.

What it means

When an AsyncIterable crosses the server-to-client boundary over Flight, React reconstructs it as a read-only stream and gives its iterator a `next()` that ignores arguments. Passing any argument to `next(arg)` is meaningless because the server side cannot receive it, so React throws to surface the misuse immediately. The iterable is intentionally argument-less; it is not a generic communication channel back to the server.

Source

Thrown at packages/react-client/src/ReactFlightClient.js:3604

      }
      closed = true;
      if (nextWriteIndex === buffer.length) {
        buffer[nextWriteIndex] =
          createPendingChunk<IteratorResult<T, T>>(response);
      }
      while (nextWriteIndex < buffer.length) {
        triggerErrorOnChunk(response, buffer[nextWriteIndex++], error);
      }
    },
  };

  const iterable: $AsyncIterable<T, T, void> = {} as any;
  // $FlowFixMe[cannot-write]
  iterable[ASYNC_ITERATOR] = (): $AsyncIterator<T, T, void> => {
    let nextReadIndex = 0;
    return createIterator(arg => {
      if (arg !== undefined) {
        throw new Error(
          'Values cannot be passed to next() of AsyncIterables passed to Client Components.',
        );
      }
      if (nextReadIndex === buffer.length) {
        if (closed) {
          // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
          return new ReactPromise(
            INITIALIZED,
            {done: true, value: undefined},
            null,
          );
        }
        buffer[nextReadIndex] =
          createPendingChunk<IteratorResult<T, T>>(response);
      }
      return buffer[nextReadIndex++];
    });
  };

View on GitHub (pinned to 22e4f993c7)

Solutions

  1. Remove the argument: call `await iter.next()` (or just use `for await (const v of iterable)`).
  2. If you genuinely need to send values back to the server, use a Server Action argument instead of the iterable's next().
  3. Wrap the iterable in your own local generator if you need value-passing semantics locally, but never pass values into the Flight-provided iterator.

Example fix

// before
const it = serverStream[Symbol.asyncIterator]();
const {value} = await it.next('resume'); // throws

// after
const {value} = await it.next(); // no argument
Defensive patterns

Strategy: validation

Validate before calling

// Wrap consumption so an accidental argument is rejected up front.
async function drain(iterable) {
  const it = iterable[Symbol.asyncIterator]();
  // Always call next() with no args.
  for (;;) {
    const {value, done} = await it.next();
    if (done) return value;
    handleChunk(value);
  }
}

Type guard

function isFlightIterable(value) {
  return value != null && typeof value[Symbol.asyncIterator] === 'function';
}
// Note: there is no public marker to distinguish a server-originated iterable;
// treat all such iterables as read-only.

Try / catch

try {
  await drain(serverIterable);
} catch (e) {
  if (e?.message?.includes('Values cannot be passed to next()')) {
    console.error('Do not pass arguments to next() of a server-originated iterable.');
  }
  throw e;
}

Prevention

When it happens

Trigger: Consuming an AsyncIterable returned from a Server Component via a `for await` loop is fine; the error only occurs when code manually calls `iter.next(someValue)` (or a helper that forwards a value) on the reconstructed client iterable. Common with custom stream consumers, generators that pass values into `next()`, or libraries that treat the iterator as two-way.

Common situations: Passing the server-originated stream into a generator-combinator (e.g. iterating with an explicit `await it.next(input)`). Migrating a local two-way async generator to one received from the server without realizing the client copy is read-only.

Related errors


AI-assisted analysis of react/react@22e4f993c7 (2026-08-12). Data as JSON: /api/errors/edeef511442df16f. Report an issue: GitHub.