Files
orca/src/shared/html-to-pdf-memory-limit.ts
T
NeilandOrca 81bfb3c396 oom(02/29): bound shared image/media/PDF memory limits (#10295)
* oom(01): A1-shared-readers — reintroduce #10179 subset

Files: 18 applied, 0 deleted (from 6eb70d8370)

Co-authored-by: Orca <help@stably.ai>

* oom(02): A2-shared-image-media — reintroduce #10179 subset

Files: 7 applied, 0 deleted (from 6eb70d8370)

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
2026-07-24 20:31:06 -07:00

14 lines
471 B
TypeScript

import { measureUtf8ByteLength } from './utf8-byte-limits'
export const HTML_TO_PDF_MAX_INPUT_BYTES = 32 * 1024 * 1024
export const HTML_TO_PDF_MEMORY_LIMIT_ERROR = 'HTML export exceeds the PDF memory limit'
export function assertHtmlToPdfInputWithinMemoryLimit(
html: string,
maxBytes = HTML_TO_PDF_MAX_INPUT_BYTES
): void {
if (measureUtf8ByteLength(html, { stopAfterBytes: maxBytes }).exceededLimit) {
throw new Error(HTML_TO_PDF_MEMORY_LIMIT_ERROR)
}
}