By the way, in iTerm2 on osx, suspending the terminal does not cause the node program to stop serving requests. It just buffers the output until you un-suspend it. I assume that at some point, that buffer will overflow, but shells are not universally consistent here.
On Wed, Mar 14, 2012 at 07:29, Ben Noordhuis <[email protected]> wrote: > On Wed, Mar 14, 2012 at 10:46, Jorge <[email protected]> wrote: >>> From: Jorge Chamorro Bieling <[email protected]> >>> Date: March 14, 2012 12:08:48 AM GMT+01:00 >>> To: Isaac Schlueter <[email protected]> >>> 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 <[email protected]> >>>> 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 ? >>> >>>> 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 >>>> [email protected] 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. > > The stress is on 'could' , it depends on your terminal settings. v0.6 > has been out for months now and no one complained so I doubt that it's > really an issue (then again, maybe no one bothered to report it). > > It's trivial to work around, either disable control characters > altogether with `stty -isig -ixon -ixoff` (also disables ^C) or > selectively with `stty kill "" stop "" susp "" quit ""`.
