Google Groups

A simple control-S in the terminal can grind to a halt any node.js server.


Jorge Mar 14, 2012 2:46 AM
Posted in group: nodejs-dev
Begin forwarded message:

> From: Jorge Chamorro Bieling <bie...@terra.es>
> Date: March 14, 2012 12:08:48 AM GMT+01:00
> To: Isaac Schlueter <i...@izs.me>
> Subject: Re: Now a simple control-S in the terminal can grind to a halt any node.js server.
> On Mar 13, 2012, at 11:56 PM, Isaac Schlueter wrote:
>>
>> On Tue, Mar 13, 2012 at 15:04, Jorge Chamorro Bieling <bie...@terra.es> wrote:
>>> Because now, it seems, that write()ing to stdout is blocking...
>>>
>>> For example:
>>>
>>> 1.- paste this in a shell:
>>>
>>> node << EOF
>>> require('http').createServer(function(req, res) {
>>> res.end("FAST");
>>> process.stdout.write('.');
>>> }).listen(8000);
>>> EOF
>>>
>>>
>>> 2.- and hit control-S
>>>
>>> 3.- then do an `ab -t 2 http://127.0.0.1:8000` in another shell, and all you'll get is :
>>>
>>> apr_poll: The timeout specified has expired (70007)
>>>
>>> Why? Because the node server is totally blocked by the control-S!
>>>
>>> Are you aware of that ?
>>> Isn't that something to be concerned about ?
>>> Why did you change write()ing to stdout to blocking ?
>>>
>>> Cheers,
>>> --
>>> Jorge.
>
>
>> This API change was made quite some time ago.  It prevents a lot of
>> confusion and edge-case bugs.
>>
>> If it causes problems for you, please bring it up on the
>> nodej...@googlegroups.com mailing list, where API changes can be
>> discussed and explored from multiple angles.
>>
>> In the meantime, I would not recommend writing to stdout on every
>> request if it might be blocked.
>>
>
>
> Isaac,
>
> It would be equally frozen whether it wrote on every request or just once.

A warning, a message, anything, just a single char written to stdout could now freeze a node.js server.
--
Jorge.