You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform: Linux cyberman 4.5.5-300.fc24.x86_64 deps: update openssl to 1.0.1j #1 SMP Thu May 19 13:05:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Subsystem: ???
I read on various sites that console.log is supposed to be synchronous in recent node.js versions. I just want to write a simple application that writes things to the terminal and exits.
However, as you can see with this simple example, huge amounts of output can be missing when simply using console.log and exiting:
var s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
for (var i = 0; i < 99999; i++) {
console.log (i + " " + s);
}
console.log ("pink");
console.error ("punk");
process.exit(0);
If you run it multiple times, you'll also get very random cutoffs for the stdout data. That goes completely against my expectations of a supposedly synchronous function..
How can console.log be used for safe output that actually arrives even when exiting the program? I would do a flush before exit, if I knew how..