{"record":{"id":"c680dec3de40e2ee","repo":"facebook/react","slug":"578","errorCode":"578","errorMessage":"Already initialized Iterator.","messagePattern":"Already initialized Iterator\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react-server/src/ReactFlightReplyServer.js","lineNumber":1206,"sourceCode":"function createSet(response: Response, model: Array<any>): Set<any> {\n  if (!isArray(model)) {\n    throw new Error('Invalid Set initializer.');\n  }\n  if ((model as any).$$consumed === true) {\n    throw new Error('Already initialized Set.');\n  }\n  // This needs to come first to prevent the model from being consumed again in case of a cyclic reference.\n  (model as any).$$consumed = true;\n  const set = new Set(model);\n  return set;\n}\n\nfunction extractIterator(response: Response, model: Array<any>): Iterator<any> {\n  if (!isArray(model)) {\n    throw new Error('Invalid Iterator initializer.');\n  }\n  if ((model as any).$$consumed === true) {\n    throw new Error('Already initialized Iterator.');\n  }\n  // This needs to come first to prevent the model from being consumed again in case of a cyclic reference.\n  (model as any).$$consumed = true;\n  // $FlowFixMe[incompatible-use]: This uses raw Symbols because we're extracting from a native array.\n  const iterator = model[Symbol.iterator]();\n  return iterator;\n}\n\nfunction createModel(\n  response: Response,\n  model: any,\n  parentObject: Object,\n  key: string,\n): any {\n  if (key === 'then' && typeof model === 'function') {\n    // This should never happen because we always serialize objects with then-functions\n    // as \"thenable\" which reduces to ReactPromise with no other fields.\n    return null;","sourceCodeStart":1188,"sourceCodeEnd":1224,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react-server/src/ReactFlightReplyServer.js#L1188-L1224","documentation":"extractIterator sets $$consumed = true on the model array before creating the iterator so cyclic references cannot consume it twice. If the same model reaches extractIterator again, the guard throws.","triggerScenarios":"The same serialized iterator model is initialized twice - cyclic structures not outlined by the encoder, duplicate references in a crafted payload, or version-skewed wire formats.","commonSituations":"Iterators over self-referential data passed to server actions; replayed or hand-edited FormData.","solutions":["Avoid passing iterators of cyclic structures as action arguments; send materialized arrays or ids instead.","Catch the error during decode and reject the request as malformed.","Align React versions across the boundary."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const args = await decodeReply(formData);\n} catch (e) {\n  return new Response('Bad request', {status: 400});\n}","preventionTips":["Prefer sending materialized arrays over iterators in action arguments.","Avoid cyclic data in anything passed to server actions.","Catch decode errors and reject the request rather than crashing the route."],"tags":["react","server-actions","deserialization","iterator","cyclic-reference"],"backgroundTag":"cyclic-reference-in-serialized-data","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}