facebook/react · error · Error
577
577
Error message
Invalid Iterator initializer.
What it means
extractIterator revives a serialized iterator by calling Symbol.iterator on the decoded model, which must be an array. A non-array model (corrupted, forged, or version-skewed payload) fails the isArray check and throws.
Source
Thrown at packages/react-server/src/ReactFlightReplyServer.js:1203
return map;
}
function createSet(response: Response, model: Array<any>): Set<any> {
if (!isArray(model)) {
throw new Error('Invalid Set initializer.');
}
if ((model as any).$$consumed === true) {
throw new Error('Already initialized Set.');
}
// This needs to come first to prevent the model from being consumed again in case of a cyclic reference.
(model as any).$$consumed = true;
const set = new Set(model);
return set;
}
function extractIterator(response: Response, model: Array<any>): Iterator<any> {
if (!isArray(model)) {
throw new Error('Invalid Iterator initializer.');
}
if ((model as any).$$consumed === true) {
throw new Error('Already initialized Iterator.');
}
// This needs to come first to prevent the model from being consumed again in case of a cyclic reference.
(model as any).$$consumed = true;
// $FlowFixMe[incompatible-use]: This uses raw Symbols because we're extracting from a native array.
const iterator = model[Symbol.iterator]();
return iterator;
}
function createModel(
response: Response,
model: any,
parentObject: Object,
key: string,
): any {
if (key === 'then' && typeof model === 'function') {View on GitHub (pinned to eafeac097b)
Solutions
- Treat the decode failure as a bad request (catch and return 400).
- Verify React version parity across the client/server boundary.
- Rate-limit and log clients that repeatedly send malformed payloads.
Defensive patterns
Strategy: try-catch
Try / catch
try {
const args = await decodeReply(formData);
} catch (e) {
return new Response('Bad request', {status: 400});
} Prevention
- Guard every decodeReply call site with a catch returning 400.
- Keep React builds consistent on both sides of the boundary.
- Cap submission size and validate content type before decoding.
When it happens
Trigger: The reply marks a chunk as an iterator but its backing model parses to a non-array value - truncated multipart bodies, hand-crafted submissions, or a different React version's wire format.
Common situations: Malformed requests hitting an action endpoint; middleware corrupting the payload; clients and servers built from different React releases.
Related errors
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/ece45282bbfef434.
Report an issue: GitHub.