Spaces:
Running
Running
File size: 2,342 Bytes
c592d77 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
getMaxPostponedStateSize: null,
getPostponedStateExceededErrorMessage: null,
readBodyWithSizeLimit: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
getMaxPostponedStateSize: function() {
return getMaxPostponedStateSize;
},
getPostponedStateExceededErrorMessage: function() {
return getPostponedStateExceededErrorMessage;
},
readBodyWithSizeLimit: function() {
return readBodyWithSizeLimit;
}
});
const _sizelimit = require("../../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")';
function getMaxPostponedStateSize(configuredMaxPostponedStateSize) {
const maxPostponedStateSize = configuredMaxPostponedStateSize ?? _sizelimit.DEFAULT_MAX_POSTPONED_STATE_SIZE;
const maxPostponedStateSizeBytes = (0, _sizelimit.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
};
}
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);
}
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 |