Bench update error Error: spawn ENOMEM

Hey guys, I am trying to do a bench update and the following errors keeps popping up at different stages of the build … has anyone encountered this issue before ?

Running:

nstalled Apps

ERPNext: v12.x.x-develop () (develop)
Frappe Framework: v12.x.x-develop () (develop)

On 18.04.2-Ubuntu

yarn run v1.21.1
$ FRAPPE_ENV=production node rollup/build.js
Production mode
✔ Built js/moment-bundle.min.js
✔ Built js/libs.min.js

Building frappe assets...

✔ Built js/dialog.min.js
✔ Built js/modules.min.js
✔ Built js/checkout.min.js
✔ Built js/social.min.js
✔ Built js/web_form.min.js
✔ Built js/chat.js
✔ Built js/list.min.js
✔ Built css/frappe-rtl.css
✔ Built css/printview.css
✔ Built css/module.min.css
✔ Built css/form.min.css
✔ Built css/list.min.css
✔ Built css/report.min.css
✔ Built frappe/css/email.css
Error: spawn ENOMEM
✔ Built js/bootstrap-4-web.min.js
internal/child_process.js:313
    throw errnoException(err, 'spawn');
    ^

Error: spawn ENOMEM
    at ChildProcess.spawn (internal/child_process.js:313:11)
    at exports.spawn (child_process.js:508:9)
    at Object.exports.fork (child_process.js:109:10)
    at ChildProcessWorker.initialize (/opt/erpnext/frappe12/apps/frappe/node_modules/jest-worker/build/workers/ChildProcessWorker.js:137:44)
    at ChildProcessWorker.onExit (/opt/erpnext/frappe12/apps/frappe/node_modules/jest-worker/build/workers/ChildProcessWorker.js:263:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)

This error is normally linked to a firewall issue. Check that the ports required are accessible

Thank you for the reply!

I opened several ports, 80, 8000, 443, 3306, but the error is the same. The difference is the error is appearing later in the build now…

After reading a bit more it seems there’s an issue with node9 as it’s running out of memory. I am running on a VPS with 2GB memory… does erpnext need more than that ?

SOLUTION:

Build your swap file and make it to turn on automatically on server reboot.

1 Like

Found some context for those who do not know how to build a swapfile on a linux server environment. Proceed with Caution. Must be run as root or sudo each command. This example sets up a 2GB swap file and only as an emergency buffer when out of memory.

install -o root -g root -m 0600 /dev/null /swapfile
dd if=/dev/zero of=/swapfile bs=1k count=2048k
mkswap /swapfile
swapon /swapfile
echo "/swapfile       swap    swap    auto      0       0" | tee -a /etc/fstab
sysctl -w vm.swappiness=10
echo vm.swappiness = 10 | tee -a /etc/sysctl.conf

If done step by step:

In the shell you have opened to your droplet, do the following:

:warning: You will need to be root for much of this, so either be root or sudo -s before running these commands! Don’t forget to exit root afterwards.

  1. Create an empty swapfile
 install -o root -g root -m 0600 /dev/null /swapfile
  1. write out a 2GB file named ‘swapfile’
 dd if=/dev/zero of=/swapfile bs=1k count=2048k
  1. tell linux this is the swap file:
 mkswap /swapfile
  1. Activate it
 swapon /swapfile
  1. Add it to the file system table so its there after reboot:
 echo "/swapfile       swap    swap    auto      0       0" | tee -a /etc/fstab
  1. Set the swappiness to 10 so its only uses as an emergency buffer
 sysctl -w vm.swappiness=10
 echo vm.swappiness = 10 | tee -a /etc/sysctl.conf

I have tried this in several production environments and it works like a charm on Ubuntu. No clue on other Linux OS
Original Source Here

1 Like

Is this doable on Ubuntu and CentOS?
Is this doable on OpenVZ and KVM?

1 Like

Thanks for this. Just came across a similar error and this worked!

FYI, I am running Ubuntu 18.04 LTS on a virtual machine.