Flotype / now

NowJS makes it easy to build real-time web apps using JavaScript
http://www.nowjs.com
MIT License
1.91k stars 175 forks source link

bug: NowJS server can be "crashed" by a user who is frantically reloading the window #61

Closed humanchimp closed 13 years ago

humanchimp commented 13 years ago

More or less, the subject line accurately describes the problem. I have created a trivial example here. If you cd to the directory, you can type either ./run or node bug2.js to see the problem for yourself.

Update: I stand corrected. It appears that this behavior is limited to Chrome. After quitting Chrome, I was occasionally able to get the test to work. Also, after opening an incognito window, I was able to reconnect to the server for some reason over xhr. I think this is probably not a bug in NowJS. Sorry for the false alarm.

tommedema commented 13 years ago

If this is possible at all in any client-side environment, this is no false alarm.

Could you define frantically reloading the window? Howmany requests/sec, by just a single client? Such behavior shouldn't cause problems.

humanchimp commented 13 years ago

My point was that it appears not be actually "crashing" the server. That much, I think I can say for now, was a false alarm.

I would define "frantically" as bombarding the keyboard with Command-R just about as fast as physically possible, maybe thirty or forty times in a row. It's not really a reasonable use-case, but it was pointed out to me by someone, and I was trying to get to the bottom of why it was happening.

Somehow, it would seem that after frantically reloading, the websocket connection in Chrome stops working. If you then reload the page again and again, at any rate of speed, it throws an error in the console saying that whatever server side method was being called is not a function (it's undefined, actually.)

One way to resolve this is to restart the server. Then, when the page is reloaded, normal communication will commence over transfer medium "websocket".

Another way is to open an Incognito window (I guess this bypasses the cookie). It will connect, but using transfer medium "xhr polling" instead of "websocket". So maybe that's a clue.

The third way to fix it is to quit Chrome and start it up again.

If you are using a browser that connects over "flashsocket" this problem seems not to exist.

In fact, it might be the sheer fastness of Chrome that gives this issue license to arrise.

Hope this helps.

ericz commented 13 years ago

This is strange. This could be either a NowJS/socket.io bug or a browser bug. I'll look into it and see if I can come to any additional insight

ericz commented 13 years ago

This doesn't seem to be a chrome issue so closing. If you guys find that part of it is a nowjs issue, feel free to reopen

tommedema commented 13 years ago

@ericz, do you mean that it is an issue within chrome? In that case, I'd like to mention that browser specific behavior should be irrelevant, as any kind of client-side logic can be implemented by anyone (meaning that if any such client side behavior would cause server side issues, this needs to be of concern).

humanchimp commented 13 years ago

I am sorry for any confusion I may have caused, @tommedema. It is my opinion that this is a Chrome browser bug, and it will only affect the user that is abusing the reload button, not other users.

tommedema commented 13 years ago

Alright, as long as it has no effect on the server that is not an issue.