facebook/react · error · Error
576
576
Error message
Invalid Set initializer.
What it means
A serialized Set is revived by createSet, which requires the decoded model to be an array of entries. If the chunk carrying the Set resolves to a non-array model, createSet throws before constructing the Set.
Source
Thrown at packages/react-server/src/ReactFlightReplyServer.js:1190
function createMap(
response: Response,
model: Array<[any, any]>,
): Map<any, any> {
if (!isArray(model)) {
throw new Error('Invalid Map initializer.');
}
if ((model as any).$$consumed === true) {
throw new Error('Already initialized Map.');
}
// 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 map = new Map(model);
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.View on GitHub (pinned to eafeac097b)
Solutions
- Catch decode failures around the action dispatch and return 400.
- Confirm both sides run the same React version.
- Log malformed submissions; they are often probes rather than real user traffic.
Defensive patterns
Strategy: try-catch
Try / catch
try {
const args = await decodeReply(formData);
} catch (e) {
return new Response('Bad request', {status: 400});
} Prevention
- Always wrap decodeReply/action dispatch in a catch that maps failures to 400.
- Keep React versions in lockstep across client and server.
- Log and alert on repeated malformed submissions.
When it happens
Trigger: The reply payload marks a chunk as a Set but its backing model parses to a non-array - corrupted or forged submissions, mutated multipart bodies, or encoder/decoder version mismatch.
Common situations: Crafted requests posted to action endpoints; proxies altering the body; stale client bundles from a different React release.
Related errors
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/e683017292a2fa66.
Report an issue: GitHub.