0
0
Node.jsframework~5 mins

Handling child process errors in Node.js - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a child process in Node.js?
A child process is a separate process created by a Node.js program to run tasks independently, allowing the main program to continue running without waiting.
Click to reveal answer
beginner
How do you listen for errors from a child process in Node.js?
You listen for the 'error' event on the child process object to catch errors like failure to start the process.
Click to reveal answer
intermediate
What does the 'exit' event on a child process indicate?
The 'exit' event fires when the child process ends. It provides the exit code and signal, which help determine if the process ended successfully or with an error.
Click to reveal answer
intermediate
Why should you handle both 'error' and 'exit' events when working with child processes?
Because 'error' catches startup failures, while 'exit' tells you if the process ended with an error code. Handling both ensures you catch all problems.
Click to reveal answer
intermediate
What is a common way to handle errors from a child process spawned with spawn()?
Attach listeners to 'error' and 'exit' events, check the exit code, and handle any error messages from stderr to respond properly.
Click to reveal answer
Which event should you listen to catch if a child process fails to start?
A'close'
B'exit'
C'error'
D'message'
What does an exit code of 0 usually mean for a child process?
AProcess ended successfully
BProcess crashed
CProcess was killed by a signal
DProcess is still running
Which Node.js method creates a child process that allows streaming input/output?
Afork()
Bexec()
CexecFile()
Dspawn()
If a child process emits an 'exit' event with a non-zero code, what does it mean?
AThe process was paused
BThe process ended with an error
CThe process is waiting for input
DThe process started successfully
Which event can you use to detect when a child process has fully closed all stdio streams?
A'close'
B'exit'
C'error'
D'disconnect'
Explain how to properly handle errors when spawning a child process in Node.js.
Think about events and exit codes.
You got /4 concepts.
    Describe the difference between the 'error' and 'exit' events on a child process.
    One is about starting, the other about ending.
    You got /4 concepts.