Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node-posix setrlimit crashes, EINVAL - Invalid argument

Tags:

node.js

posix

The following coed gives me an EINVAL error and Node crashes:

var posix = require('posix');
console.log(posix.getrlimit('nofile'));
posix.setrlimit('nofile', {soft: 10000});


ERROR:

/var/myfil/index.js:19
posix.setrlimit('nofile', {soft: 10000});
      ^
Error: EINVAL, Invalid argument
    at Object.<anonymous> (/var/myfile/index.js:19:7)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

What is the problem? It's exactly like the docs.

like image 310
apscience Avatar asked Sep 26 '13 01:09

apscience


1 Answers

That happens if you try to set a soft limit that's higher than the hard limit.

Try setting them both:

posix.setrlimit('nofile', { soft: 10000, hard: 10000 });
like image 82
Gray Fox Avatar answered Sep 17 '22 23:09

Gray Fox