React-pdf: JavaScript heap out of memory

Created on 18 Sep 2017  路  7Comments  路  Source: wojtekmaj/react-pdf

I'm experiencing memory errors on node build.
This is only the case when react-pdf is included and used in the project.

The command:

node react-scripts build

The error:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

I even added the memory argument

node --max-old-space-size=8192 react-scripts build

In the package.json

"react-pdf": "^2.1.1",

Please advice

Most helpful comment

I'm experiencing memory errors on node build.
This is only the case when react-pdf is included and used in the project.

The command:

node react-scripts build

The error:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

I even added the memory argument

node --max-old-space-size=8192 react-scripts build

In the package.json

"react-pdf": "^2.1.1",

Please advice

I have this exact problem immediately I added react-pdf library to my project. When I comment out it's imports, everything works fine until I uncomment them. Meaning the problem is with the library. Kindly help.

All 7 comments

Hey @hanselsen,
Sadly I have no knowledge about react-scripts and this looks like issue on their side. I personally use Webpack to build the project and although it takes quite a bit of time (sometimes over 2 minutes), it always finishes. Not sure what react-scripts has under the hood. Could you drop them a note, too?
Thanks,
Wojciech

@wojtekmaj I use webpack too. It also takes a long time. (6 minutes in the past, but I managed to speed that up luckily). Is the React-PDF package so big that by adding it, it just claims all memory available? Or do you have no experience with this?

@hanselsen React-PDF itself is rather tiny. Takes a couple of seconds to pack it. However its dependency, mozilla/react.pdf, is something waaaay bigger.
Webpack had this thing called cacheDirectory when you use babel-loader, maybe this would help you? I guess pushing ~1 MB of pure minified Mozilla's code through every time might be problematic.

@hanselsen I'm closing this in effort to keep Issues page clean of issues that are no longer discussed. I will be happy to reopen in case you still have this issue!

Hello, I had the same issue.
So I updated me package.json : react-scripts --max_old_space_size=4096 build
It worked out for me :)

I'm experiencing memory errors on node build.
This is only the case when react-pdf is included and used in the project.

The command:

node react-scripts build

The error:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

I even added the memory argument

node --max-old-space-size=8192 react-scripts build

In the package.json

"react-pdf": "^2.1.1",

Please advice

I have this exact problem immediately I added react-pdf library to my project. When I comment out it's imports, everything works fine until I uncomment them. Meaning the problem is with the library. Kindly help.

i got same problem.
i solved the problem. please follow the issue:
https://github.com/mozilla/pdf.js/issues/11468

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Crackiii picture Crackiii  路  3Comments

Vanals picture Vanals  路  4Comments

wojtekmaj picture wojtekmaj  路  4Comments

varand-pez picture varand-pez  路  3Comments

douglasrcjames picture douglasrcjames  路  4Comments