My Node.js script crashes due to an ENOMEM (Out of memory) errnoException failure when using spawn .
Mistake:
child_process.js:935 throw errnoException(process._errno, 'spawn'); ^ Error: spawn ENOMEM at errnoException (child_process.js:988:11) at ChildProcess.spawn (child_process.js:935:11) at Object.exports.spawn (child_process.js:723:9) at module.exports ([...]/node_modules/zbarimg/index.js:19:23)
I already use listeners for error and exit events, but they do not fire in the event of this error.
My code is:
zbarimg = process.spawn('zbarimg', [photo, '-q']); zbarimg.on('error', function(err) { ... }); zbarimg.on('close', function(code) { ... });
Full source code is available .
Is there anything I can do to prevent the script from crashing? How to catch the thrown ENOMEM error?
Thank!
tobi 04 Oct '14 at 14:13 2014-10-04 14:13
source share