Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Node.js console.log synchronous
console.log('stdout._type:', process.stdout._type);
process.nextTick(function() {
process.on('exit', function(code) {
process.nextTick(function() {
console.log('This does not run, as the docs say.');
console.log('This should not run if proces.stdout._type is pipe.');
console.log("isTTY: ", process.stdout.isTTY);
// per, I expect this time to be before both x and y if terminal, and after if piped.
// invalid: parameter to console.log gets evaluated instantly, regardless of whether the log() function blocks or not.
console.log("Logged at: " + process.hrtime());
x = process.hrtime();
y = (function() {return process.hrtime()})();
console.log("x: " + x);
console.log("y: " + y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment