Open jdmairs opened 4 years ago
So I'm using forever-monitor to spawn a c++ executable. It works great. I then purposefully delete the executable to test my error handling in Express.
export async function startProcess(): Promise<void> { return new Promise((resolve, reject) => { const child = forever.start(['./Foo'], { max: 1, }); child.on('exit', () => { getLogger('NewJobNanny').info('Foo has exited gracefully'); resolve(); }); child.on('stdout', (data: any) => { getLogger('NewJobNanny').info('Detecting stdout ', data); }); child.on('error', (error) => { getLogger('NewJobNanny').error('startProcess detected error: ', error); reject(error); }); });
I have a catch on startProcess but it does not catch. Instead my node/express app crashes with the following
events.js:200 throw er; // Unhandled 'error' event ^
Error: spawn ./Foo ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19) at onErrorNT (internal/child_process.js:456:16) at processTicksAndRejections (internal/process/task_queues.js:81:21) Emitted 'error' event on ChildProcess instance at: at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12) at onErrorNT (internal/child_process.js:456:16) at processTicksAndRejections (internal/process/task_queues.js:81:21) { errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn ./Foo', path: './Foo', spawnargs: [] }
So I'm using forever-monitor to spawn a c++ executable. It works great. I then purposefully delete the executable to test my error handling in Express.
I have a catch on startProcess but it does not catch. Instead my node/express app crashes with the following
events.js:200 throw er; // Unhandled 'error' event ^
Error: spawn ./Foo ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19) at onErrorNT (internal/child_process.js:456:16) at processTicksAndRejections (internal/process/task_queues.js:81:21) Emitted 'error' event on ChildProcess instance at: at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12) at onErrorNT (internal/child_process.js:456:16) at processTicksAndRejections (internal/process/task_queues.js:81:21) { errno: 'ENOENT', code: 'ENOENT', syscall: 'spawn ./Foo', path: './Foo', spawnargs: [] }