Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF generation with nodejs > 16 fails with RangeError #2543

Closed
chaselmann opened this issue Feb 7, 2023 · 3 comments
Closed

PDF generation with nodejs > 16 fails with RangeError #2543

chaselmann opened this issue Feb 7, 2023 · 3 comments
Labels
Milestone

Comments

@chaselmann
Copy link

chaselmann commented Feb 7, 2023

Server-side pdf generation with nodejs version > 16 fails with the following error:

RangeError [ERR_OUT_OF_RANGE]: The value of "size" is out of range. It must be <= 1GiB. Received 9_007_199_254_740_991
     at new NodeError (node:internal/errors:393:5)
     at computeNewHighWaterMark (node:internal/streams/readable:368:11)
     at Readable.read (node:internal/streams/readable:416:27)
     at PDFDocument.<anonymous> (/home/app/.yarn/cache/pdfmake-npm-0.3.0-beta.2-7d513f8c84-58ad2341ec.zip/node_modules/pdfmake/js/OutputDocument.js:37:36)
     at PDFDocument.emit (node:events:513:28)
     at emitReadable_ (node:internal/streams/readable:590:12)
     at process.processTicksAndRejections (node:internal/process/task_queues:81:21) {
    code: 'ERR_OUT_OF_RANGE'
}

This error occurs since nodejs version 18 because the implementation for the computation of the high watermark in node streams changed. In nodejs v16 the hight watermark value was overriden with the max allowed value (1GB), In nodejs v18 an error is thrown if the max value is exceeded.

To fix this error the default value in OutputDocument.js bufferSize should be changed from currently 9007199254740991 to 0x40000000 (1GB)

@liborm85 liborm85 added the bug label Feb 12, 2023
@liborm85 liborm85 added this to the 0.3.0 milestone Feb 12, 2023
liborm85 added a commit that referenced this issue Feb 12, 2023
@liborm85
Copy link
Collaborator

Thanks for testing. Fixed by commit d9b5b9e.

@BKSnake
Copy link

BKSnake commented Feb 19, 2023

When this fix will be present in beta version?

Could you make new version of pdfmake? I need use node 18

@liborm85
Copy link
Collaborator

0.3.0-beta.5 released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants