This repository has been archived on 2026-05-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
novarix-networks-homepage/node_modules/next/dist/esm/server/lib/postponed-request-body.js
T
Kismet Hasanaj 34dc9aec52 .
2026-05-02 20:07:02 +02:00

38 lines
1.7 KiB
JavaScript

import { DEFAULT_MAX_POSTPONED_STATE_SIZE, parseMaxPostponedStateSize } from '../../shared/lib/size-limit';
const INVALID_MAX_POSTPONED_STATE_SIZE_ERROR_MESSAGE = 'maxPostponedStateSize must be a valid number (bytes) or filesize format string (e.g., "5mb")';
export function getMaxPostponedStateSize(configuredMaxPostponedStateSize) {
const maxPostponedStateSize = configuredMaxPostponedStateSize ?? DEFAULT_MAX_POSTPONED_STATE_SIZE;
const maxPostponedStateSizeBytes = parseMaxPostponedStateSize(configuredMaxPostponedStateSize);
if (maxPostponedStateSizeBytes === undefined) {
throw Object.defineProperty(new Error(INVALID_MAX_POSTPONED_STATE_SIZE_ERROR_MESSAGE), "__NEXT_ERROR_CODE", {
value: "E977",
enumerable: false,
configurable: true
});
}
return {
maxPostponedStateSize,
maxPostponedStateSizeBytes
};
}
export function getPostponedStateExceededErrorMessage(maxPostponedStateSize) {
return `Postponed state exceeded ${maxPostponedStateSize} limit. ` + `To configure the limit, see: https://nextjs.org/docs/app/api-reference/config/next-config-js/max-postponed-state-size`;
}
function toBuffer(chunk) {
return Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
}
export async function readBodyWithSizeLimit(body, maxBodySizeBytes) {
const chunks = [];
let size = 0;
for await (const chunk of body){
const buffer = toBuffer(chunk);
size += buffer.byteLength;
if (size > maxBodySizeBytes) {
return null;
}
chunks.push(buffer);
}
return Buffer.concat(chunks);
}
//# sourceMappingURL=postponed-request-body.js.map