{"record":{"id":"2073dc737913624e","repo":"facebook/react","slug":"524","errorCode":"524","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-server/src/ReactFlightReplyServer.js","lineNumber":1566,"sourceCode":"        return;\n      }\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  const iterable: $AsyncIterable<T, T, void> = {\n    [ASYNC_ITERATOR](): $AsyncIterator<T, T, void> {\n      let nextReadIndex = 0;\n      // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors\n      return new FlightIterator((arg: void) => {\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":1548,"sourceCodeEnd":1584,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server/src/ReactFlightReplyServer.js#L1548-L1584","documentation":"Async iterables returned from the server are replayed on the client through a FlightIterator whose next() accepts no argument: the Flight protocol only transports values server-to-client. Generator-style two-way communication (it.next(x)) cannot be carried over the boundary, so any non-undefined argument throws.","triggerScenarios":"Client code treats a server-provided async iterator like a local generator and calls await it.next(someValue); or a library whose contract forwards an input into next() (task pools, pipeline utilities) consumes the server iterable.","commonSituations":"Porting generator-based pipelines to RSC; feeding server streams into libraries that call next(input) by design.","solutions":["Drain server iterables with bare next() calls (no argument).","If you must send data per iteration, call a server action instead of pushing values into the iterator.","Wrap the iterator so incidental arguments are stripped before reaching Flight's iterator."],"exampleFix":"// before\nconst it = serverIterable[Symbol.asyncIterator]();\nconst {value} = await it.next(requestPayload); // throws\n\n// after\nconst it = serverIterable[Symbol.asyncIterator]();\nconst {value} = await it.next(); // no argument\nconst result = await doWorkServerAction(requestPayload); // send data via an action","handlingStrategy":"validation","validationCode":"// safe drain helper: always calls next() with no argument\nasync function* drain<T>(it: AsyncIterator<T>): AsyncGenerator<T> {\n  let r = await it.next();\n  while (!r.done) {\n    yield r.value;\n    r = await it.next();\n  }\n}\n// wrap any third-party consumer input:\nconst safe = drain(serverIterable[Symbol.asyncIterator]());","typeGuard":null,"tryCatchPattern":"try {\n  const r = await it.next();\n} catch (e) {\n  if (String(e).includes('AsyncIterables passed to Client Components')) {\n    // call site is forwarding a value into next(); refactor it to bare next()\n  }\n  throw e;\n}","preventionTips":["Always call next() with no arguments on iterables that came from the server.","Send per-iteration data through server actions, not through iterator arguments.","When feeding server iterables to libraries that pass values to next(), wrap them with a bare-next adapter first."],"tags":["react","server-components","async-iterator","use","flight-protocol"],"backgroundTag":"async-iterator-protocol-misuse","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}