Writes to process.stdout are synchronous when the destination is a file or a TTY on POSIX, but asynchronous when it is a pipe. Calling process.exit() right after a large console.log therefore drops output only when the command is piped, redirected into a subprocess, or run under a CI log collector, and looks fine in an interactive terminal.
Reproduce it by printing a few hundred kilobytes and exiting immediately, then comparing node script.js | wc -c against node script.js > /dev/null timing or a direct run. The tail of the output goes missing in the piped case.
The fix is to stop calling process.exit() for normal completion. Set process.exitCode = 1 and let the event loop drain, which flushes pending writes before the process ends. If an immediate exit is genuinely required, wait for the drain event or use the callback form of stream.write before exiting. This behavior is documented and unchanged through Node 24.