Performance: Handling child process errors
MEDIUM IMPACT
This concept affects the responsiveness and stability of Node.js applications by managing error events from child processes, preventing crashes and blocking operations.
import { spawn } from 'child_process'; const child = spawn('someCommand'); child.on('error', err => { console.error('Child process error:', err); // Handle error gracefully }); child.stdout.on('data', data => console.log(`Output: ${data}`));
import { spawn } from 'child_process'; const child = spawn('someCommand'); // No error event listener child.stdout.on('data', data => console.log(`Output: ${data}`));
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No error handling on child process | N/A | N/A | N/A | [X] Bad |
| Proper error event listener on child process | N/A | N/A | N/A | [OK] Good |