facebook/react · error · Error

575

575

Error message

Invalid Map initializer.

What it means

A serialized Map is revived by createMap, which requires the decoded model to be an array of key/value pairs. If the chunk carrying the Map resolves to a non-array model, createMap throws before constructing the Map.

Source

Thrown at packages/react-server/src/ReactFlightReplyServer.js:1177

        initializingHandler = {
          chunk: null,
          value: null,
          reason: chunk.reason,
          deps: 0,
          errored: true,
        };
      }
      // Placeholder
      return null as any;
  }
}

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.

View on GitHub (pinned to eafeac097b)

Solutions

  1. Wrap action/decodeReply handling in a catch and return 400 for malformed payloads.
  2. Verify client and server React versions match and redeploy together.
  3. Treat all reply payloads as untrusted input; log and rate-limit repeated offenders.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const args = await decodeReply(formData);
} catch (e) {
  return new Response('Bad request', {status: 400});
}

Prevention

When it happens

Trigger: The reply payload marks a chunk as a Map but its backing model parses to a non-array - corrupted submissions, mutated multipart bodies, or an encoder from a mismatched React version.

Common situations: Forged requests to an action endpoint; payload corruption through proxies; version skew between the client that serialized the Map and the server that revives it.

Related errors


AI-assisted analysis of facebook/react@eafeac097b (2026-08-21). Data as JSON: /api/errors/10cee0fd703a664a. Report an issue: GitHub.