kontent-ai-bot / backup-manager-js

This utility enables backup & restore of Kontent.ai projects
https://kontent.ai
MIT License
7 stars 7 forks source link

Creating Zip failes due to filesize #17

Open jsnet-ops opened 3 years ago

jsnet-ops commented 3 years ago

At the "Create zip file" stage following error occurs:

There was an error processing your request: RangeError [ERR_INVALID_ARG_VALUE]: The argument 'size' is invalid. Received 4620737532 at Function.allocUnsafe (node:buffer:374:3) at Function.concat (node:buffer:553:25) at concat (/usr/lib/node_modules/@kentico/kontent-backup-manager/node_modules/jszip/lib/stream/StreamHelper.js:62:27) at StreamHelper. (/usr/lib/node_modules/@kentico/kontent-backup-manager/node_modules/jszip/lib/stream/StreamHelper.js:96:61) at Immediate._onImmediate (/usr/lib/node_modules/@kentico/kontent-backup-manager/node_modules/jszip/lib/utils.js:381:18) at processImmediate (node:internal/timers:464:21) { code: 'ERR_INVALID_ARG_VALUE' }

This seems to be JSZip related, although size is not a known restriction.

Versions used: Ubuntu 20.04 (In Docker) Node: v16.1.0 npm: 7.11.2 jszip: 3.6.0

Enngage commented 3 years ago

@sojwil, node.js processes are limited by the amount of memory they can use by default. I think that for standard processes its 512 MB, but that can be increased with --max_old_space_size setting.

I have limited experience with this, but in the past I've used following script to increase memory for my Angular build process where the default was not enough:

node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng

You can also read some more about this here - https://stackoverflow.com/questions/48387040/how-do-i-determine-the-correct-max-old-space-size-for-node-js

Let me know if you are able to get it working with the settings so I can potentially update documentation, thank you :-)

jsnet-ops commented 3 years ago

Hi Enngage,

Thanks for your help. As recommended, I started the backup like this:

node --max-old-space-size=8192 ./_commonjs/src/node-js/cli/app.js --action=backup --apiKey=xxx --projectId=xxxx --zipFilename=bak

Also, I added some extra debug info to zip.service.ts to make sure the right amount is memory (8192) is allocated and no overruns occur. Still the same error msg.

Any other suggestions are very welcome.