facebook/react · error · Error
Type ${typeof value} is not supported as an argument to a Se
Error message
Type ${typeof value} is not supported as an argument to a Server Function. What it means
This is the final catch-all at the end of serializeArgument in the reply serializer. Every supported category has been checked by this point - primitives, elements, lazy, server references, client functions, symbols, bigint, plain objects and built-ins - so reaching the last throw means the value's typeof matches no supported slot. In practice this fires only for exotic values whose reported typeof is misleading (e.g. document.all reporting 'undefined', cross-realm/VM objects) or future host exotica; for ordinary JS values the earlier branches throw their own specific messages.
Source
Thrown at packages/react-client/src/ReactFlightReplyClient.js:877
// through the property name inside that parent.
const reference = parentReference + ':' + key;
// Store this object so that the server can refer to it later in responses.
writeTemporaryReference(temporaryReferences, reference, value);
return serializeTemporaryReferenceMarker();
}
}
throw new Error(
'Symbols cannot be passed to a Server Function without a ' +
'temporary reference set. Pass a TemporaryReferenceSet to the options.' +
(__DEV__ ? describeObjectForErrorMessage(parent, key) : ''),
);
}
if (typeof value === 'bigint') {
return serializeBigInt(value);
}
throw new Error(
`Type ${typeof value} is not supported as an argument to a Server Function.`,
);
}
function serializeModel(model: ReactServerValue, id: number): string {
if (typeof model === 'object' && model !== null) {
const reference = serializeByValueID(id);
writtenObjects.set(model, reference);
if (temporaryReferences !== undefined) {
// Store this object so that the server can refer to it later in responses.
writeTemporaryReference(temporaryReferences, reference, model);
}
}
modelRoot = model;
// $FlowFixMe[incompatible-type] it's not going to be undefined because we'll encode it.
return JSON.stringify(model, resolveToJSON);
}
View on GitHub (pinned to eafeac097b)
Solutions
- Dry-run encodeReply(args) locally inside try/catch to identify which argument value falls through, then replace it with a serializable representation
- Convert exotic values to plain data before the call (e.g. String(el.id), a plain DTO) or pass an ID and rehydrate on the server
- If realm-crossing objects are involved, reconstruct the value in the main realm first
- Report genuinely unsupported value types to the React team if a legitimate use case hits the catch-all
Example fix
// before
await saveSelection({node: document.all, ok: true}); // exotic typeof -> catch-all throw
// after
await saveSelection({nodeId: el?.id ?? null, ok: true}); // plain data only Defensive patterns
Strategy: try-catch
Validate before calling
// Dry-run the serialization locally to catch exotic values before the network call
import {encodeReply} from 'react-server-dom-webpack/client';
async function assertReplyEncodable(args: unknown) {
try {
await encodeReply(args);
} catch (e) {
throw new Error(`Arguments not serializable for Server Function call: ${(e as Error).message}`);
}
} Try / catch
try {
await myServerFunction(args);
} catch (e) {
if (e instanceof Error && /is not supported as an argument to a Server Function/.test(e.message)) {
// Re-run encodeReply(args) locally to locate the offending value,
// replace it with plain data or an ID, then retry the call once
} else throw e;
} Prevention
- Dry-run encodeReply over complex args during development
- Keep Server Function payloads limited to plain data, built-ins, and IDs
- Avoid forwarding host objects, DOM nodes, or cross-realm values into actions
- Log failing argument shapes once to build a project-specific allowlist
When it happens
Trigger: Passing host exotica like document.all, values from another VM realm/context whose typeof is inconsistent, or objects with spoofed/mutated prototypes engineered to dodge the earlier branches; any argument that slips past every typed branch of serializeArgument.
Common situations: Sending DOM/window objects that masquerade as primitives; test doubles and Proxy objects with exotic behavior; serializing values produced in node:vm or jsdom realms; almost never seen with plain application data - if you see it, an unusual object reached the boundary.
Related errors
- Missing a temporary reference set but the RSC response retur
- Invalid reference.
- Trying to call a function from "use server" but the callServ
- React Element cannot be passed to Server Functions from the
- Only plain objects, and a few built-ins, can be passed to Se
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/b5a9daac5f2a90cf.
Report an issue: GitHub.