fs.writeSync()
The Node.js function that writes to a file descriptor and returns only when the write is done, blocking the thread meanwhile.
In more detail
In a crash handler it guarantees the message is written before the process ends: fs.writeSync(2, text) writes to standard error. Outside such special cases prefer the asynchronous versions, because synchronous writes block the event loop.
Related terms
- synchronous code — Code that runs start to finish without pausing, so the next line waits for it to complete.
- standard output and standard error — The two channels a program writes normal output (stdout) and error messages (stderr) to, plus stdin for input.
- uncaughtExceptionMonitor — A Node.js process event emitted just before an uncaught exception is handled, letting you record it without stopping the crash.
Taught in
- Global Error Trapping: uncaughtException & Exits — Node.js Internals & Backend Services