facebook/react · error · Error
581
581
Error message
BigInt is too large. Received %s digits but the limit is %s.
What it means
React caps how many digits a serialized BigInt may carry when a client reply (server action arguments) is decoded, and rejects anything larger than MAX_BIGINT_DIGITS (300 in this tree). Parsing cost for BigInt grows with digit count, so unbounded numeric payloads are a denial-of-service vector against action endpoints. The message reports both the received digit count and the hard limit.
Source
Thrown at packages/react-server/src/ReactFlightReplyServer.js:1731
}
case 'N': {
// $NaN
return NaN;
}
case 'u': {
// matches "$undefined"
// Special encoding for `undefined` which can't be serialized as JSON otherwise.
return undefined;
}
case 'D': {
// Date
return new Date(Date.parse(value.slice(2)));
}
case 'n': {
// BigInt
const bigIntStr = value.slice(2);
if (bigIntStr.length > MAX_BIGINT_DIGITS) {
throw new Error(
'BigInt is too large. Received ' +
bigIntStr.length +
' digits but the limit is ' +
MAX_BIGINT_DIGITS +
'.',
);
}
if (arrayRoot !== null) {
bumpArrayCount(arrayRoot, bigIntStr.length, response);
}
return BigInt(bigIntStr);
}
case 'A':
return parseTypedArray(
response,
value,
ArrayBuffer,
1,View on GitHub (pinned to eafeac097b)
Solutions
- Send the value as a string and convert to BigInt inside the server action.
- Validate and limit numeric input length on the client before invoking the action.
- If giant integers are genuinely needed, encode them (hex/base64 string) and decode server-side.
Example fix
// before
<form action={updateBalance(BigInt(balanceDigits))}>
// after — pass a string, parse on the server
'use server';
export async function updateBalance(digits: string) {
if (digits.length > 300) throw new Error('balance too large');
const value = BigInt(digits);
// ...
} Defensive patterns
Strategy: validation
Validate before calling
const MAX_BIGINT_DIGITS = 300; // match React's limit
export function assertSafeBigIntArgs(args: unknown[]) {
for (const a of args) {
if (typeof a === 'bigint' && a.toString().length > MAX_BIGINT_DIGITS) {
throw new Error('BigInt argument exceeds ' + MAX_BIGINT_DIGITS + ' digits');
}
}
} Type guard
export function isSerializableBigInt(v: unknown): v is bigint {
return typeof v !== 'bigint' || v.toString().length <= 300;
} Prevention
- Never feed raw external numeric input straight into a BigInt action argument.
- Cap numeric field length on the client before invoking server actions.
- Prefer string transport for very large numbers.
When it happens
Trigger: Invoking a server action whose argument is a BigInt whose string form exceeds 300 digits, e.g. doThing(BigInt(hugeDigits)); serializing a big-number library output (bn.js, bigint-converted Decimal) into action arguments or client reply payloads.
Common situations: Passing token IDs, snowflake IDs, hashes, or crypto values as BigInt in action args; fuzz/test payloads with randomly generated huge numbers; converting decimal library results straight to BigInt before an action call.
Related errors
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/687da0af81a10dcb.
Report an issue: GitHub.