jesusabdullah/node-ecstatic — pull request #92 by remixz (2013-12-17 22:53:23+00:00)
Title: Fix gzip requests being fired twice

Hey! For a while at DIY, we had abstained from having gzip enabled for static files, because they would hang on our servers. I decided to properly look into that today, and found the issue. What was happening was that inside the check on the `fs.stat` of the `gzipped` file, it was calling return, but inside the `fs.stat` scope. This means that it wasn't doing a returning in the scope before, which caused `fs.stat` to be called twice, along with `serve`. This lead to the wrong file and stats being returned, which caused the hang.

I fixed it by scoping the non-gzipped file stat check inside a function. It's a messy solution, so I'm open to any changes that would make it better.