{"record":{"id":"3bbfc88b05e15d02","repo":"facebook/react","slug":"values-cannot-be-passed-to-next-of-asynciterable","errorCode":null,"errorMessage":"Values cannot be passed to next() of AsyncIterables passed to Client Components.","messagePattern":"Values cannot be passed to next\\(\\) of AsyncIterables passed to Client Components\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-client/src/ReactFlightClient.js","lineNumber":3604,"sourceCode":"      }\n      closed = true;\n      if (nextWriteIndex === buffer.length) {\n        buffer[nextWriteIndex] =\n          createPendingChunk<IteratorResult<T, T>>(response);\n      }\n      while (nextWriteIndex < buffer.length) {\n        triggerErrorOnChunk(response, buffer[nextWriteIndex++], error);\n      }\n    },\n  };\n\n  const iterable: $AsyncIterable<T, T, void> = {} as any;\n  // $FlowFixMe[cannot-write]\n  iterable[ASYNC_ITERATOR] = (): $AsyncIterator<T, T, void> => {\n    let nextReadIndex = 0;\n    return createIterator(arg => {\n      if (arg !== undefined) {\n        throw new Error(\n          'Values cannot be passed to next() of AsyncIterables passed to Client Components.',\n        );\n      }\n      if (nextReadIndex === buffer.length) {\n        if (closed) {\n          // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors\n          return new ReactPromise(\n            INITIALIZED,\n            {done: true, value: undefined},\n            null,\n          );\n        }\n        buffer[nextReadIndex] =\n          createPendingChunk<IteratorResult<T, T>>(response);\n      }\n      return buffer[nextReadIndex++];\n    });\n  };","sourceCodeStart":3586,"sourceCodeEnd":3622,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-client/src/ReactFlightClient.js#L3586-L3622","documentation":"When an AsyncIterable crosses the server-to-client boundary, React constructs a client-side iterator that streams values out of the Flight payload. The wire protocol is one-way: there is no channel to push a value back to the server, so the generated next() throws if you pass any argument other than undefined. It protects the protocol from being misused as a duplex stream.","triggerScenarios":"Manually calling iterator.next(someValue) on an AsyncIterable received from a Server Component / Server Function; wiring the server iterable into a helper that forwards values to next() (e.g. bridging into another generator or Rx pipeline that passes arguments); using yield* delegation where values are sent downstream.","commonSituations":"Treating a server-passed stream like a socket or channel; adapter code written for general AsyncIterables that happens to call next(arg); protocols like some RPC/stream libraries that use next(value) for backpressure or cancellation signalling.","solutions":["Call next() with no arguments (or explicitly undefined) on server-passed iterables","Use for await...of to consume the stream - it never passes a value to next()","If you need bidirectional communication, use a different transport (WebSocket, or calling Server Functions from the client) - RSC iterables are read-only","Wrap the iterator in a facade whose next() drops arguments before passing it to value-forwarding helpers"],"exampleFix":"// before\nconst it = serverIterable[Symbol.asyncIterator]();\nwhile (true) {\n  const {value, done} = await it.next(signal); // passing a value -> throws\n  if (done) break;\n  handle(value);\n}\n\n// after\nfor await (const value of serverIterable) {\n  handle(value);\n}","handlingStrategy":"validation","validationCode":"// Wrap server iterables before handing them to value-forwarding helpers\nconst oneWay = <T>(it: AsyncIterator<T>) => ({\n  next: () => it.next(), // drops any argument a caller tries to send\n  [Symbol.asyncIterator]() { return this; },\n});","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat server-passed AsyncIterables as read-only streams","Consume them with for await...of, which never passes values to next()","Do not bridge them into generator delegation (yield*) or pipelines that call next(value)","Use WebSockets or Server Function calls when you need bidirectional flow"],"tags":["rsc","async-iterable","streaming","flight","iterator-protocol"],"backgroundTag":"async-iterable-next-value","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}