Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js unresponsive until key press on console

I have a Node.js app, that runs on a Windows Server 2008. I'm facing a weird problem here.

My app does more than one async tasks. Sending data to socket.io, MySQL, HTTP connections, TCP connections etc.

My Node app becomes unresponsive especially on the socket.io end, and only starts responding back again after any key press on the console. Is this a known issue? Any bypasses around such a behavior?

Note: I am using console.log heavily to keep track of the current operation and errors in process.

like image 906
Omkar Khair Avatar asked May 15 '13 05:05

Omkar Khair


People also ask

Does console log slow down node?

As stderr is always written to synchronously, therefore in node. js any use of console. error, or other functions that write to stderr, will block your process until the output has all been written. The method is useful for error messages, but excessive use could slow down your process.

Why is node js not working?

Problems occurring in Node. js application deployments can have a range of symptoms, but can generally be categorized into the following: Uncaught exception or error event in JavaScript code. Excessive memory usage, which may result in an out-of-memory error.

How do I use console commands in node JS?

log() function from console class of Node. js is used to display the messages on the console. It prints to stdout with newline. Parameter: This function contains multiple parameters which are to be printed.


1 Answers

I did a bit of a background check and came to the following conclusions.

The Powershell console on Windows Server 2008 goes on a 'pause' mode when clicked on it. It is released again if you click elsewhere. http://www.vistax64.com/powershell/112032-script-pauses-when-you-click-powershell-text-window.html

If you notice, console.log is async. But console.warn and console.error are blocking. These are not async.

The console pause might block some/most part of the Node.js operations. Esp. as Socket.io at default debugging level will report with more than just console.log.

like image 101
Omkar Khair Avatar answered Sep 20 '22 12:09

Omkar Khair