Complete the code to listen for uncaught exceptions and log the error.
process.on('uncaughtException', (err) => { console.error('Uncaught Exception:', [1]); });
err.message which hides stack trace.The err object contains the error details. Logging err shows the full error.
Complete the code to listen for unhandled promise rejections and log the reason.
process.on('unhandledRejection', (reason, promise) => { console.error('Unhandled Rejection at:', [1]); });
The reason parameter contains why the promise was rejected. Logging it helps diagnose the issue.
Fix the error in the code to properly close the server on SIGINT signal.
process.on('SIGINT', () => { console.log('SIGINT received, shutting down...'); server.[1](() => { console.log('Server closed'); process.exit(0); }); });
shutdown or stop.process.exit() after closing.The server.close() method stops the server from accepting new connections and calls the callback when done.
Fill both blanks to log the error and exit the process with failure code.
process.on('uncaughtException', (err) => { console.error('Error:', [1]); process.[2](1); });
process.abort() which causes a core dump.Logging the error object err shows details. Using process.exit(1) exits with failure status.
Fill all three blanks to handle SIGTERM by closing the server and exiting cleanly.
process.on('[1]', () => { console.log('Signal received, closing server...'); server.[2](() => { console.log('Server closed, exiting.'); process.[3](0); }); });
SIGINT with SIGTERM.process.exit() after closing the server.SIGTERM is the termination signal. server.close() stops the server. process.exit(0) exits successfully.