greenlaw110 / greenscript

A tool help web developers manage javascript/css rendering, including minimize and dependence management
42 stars 24 forks source link

Parsing error on concurrent requests #38

Open bgkittrell opened 12 years ago

bgkittrell commented 12 years ago

First off all, thanks for CoffeeScript support, it came just in time.

I believe I found an issue. It seems that after you start a server with minimization on, if you hit a page multiple times before greenscript is done compiling, you get an exception.

I'm using Play 1.2.4 and Greenscript 1.2.8, with minimization and compression enabled. We are using #{greenscript tags in main.html to load javascript and coffeescript.

The exception is

54423 [play-thread-2] ERROR com.greenscriptool.Minimizer - error compile coffee script file org.jcoffeescript.JCoffeeScriptCompileException: Error: too many ) on line 2 at org.jcoffeescript.JCoffeeScriptCompiler.compile(JCoffeeScriptCompiler.java:80) at com.greenscriptool.Minimizer.compileCoffee(Minimizer.java:487) at com.greenscriptool.Minimizer.compileCoffee(Minimizer.java:491) at com.greenscriptool.Minimizer.preprocess(Minimizer.java:805) at com.greenscriptool.Minimizer.merge(Minimizer.java:733) at com.greenscriptool.Minimizer.minimize(Minimizer.java:512) at com.greenscriptool.Minimizer.minimize_(Minimizer.java:568) at com.greenscriptool.Minimizer.process(Minimizer.java:359) at com.greenscriptool.RenderSession.output(RenderSession.java:141) at com.greenscriptool.IRenderSession$output.call(Unknown Source) at Template_1114$_runclosure1.doCall(output.html:12)

The actual parse error changes everytime, and if I disable minimization the coffeescript compiles just fine. My guess is that the problem lies on this line, in ClosureCompiler#compile

42 JSSourceFile file = JSSourceFile.fromInputStream("greenscript.js", new ReaderInputStream(r));

It seems to me that if this was called multiple times, then multiple threads would have a handle on the greescript.js file, and could be streaming to it simultaneously, resulting in a corrupt file. That's just a guess.

I'd be happy to take a crack at fixing it, but wanted to run it by you guys since this is new code to me.

bgkittrell commented 12 years ago

FYI, I don't think the closureCompiler method is the problem any more. I had my wires crossed. I'm still trying to pinpoint this, but it's definitely a problem with two concurrent minimize processes.

greenlaw110 commented 12 years ago

Hi Ben,

Thank you for very much for reporting the bug. Your contribution will be greatly appreciated.

Regards, Green

On Tue, Feb 21, 2012 at 3:46 AM, Ben Kittrell < reply@reply.github.com

wrote:

First off all, thanks for CoffeeScript support, it came just in time.

I believe I found an issue. It seems that after you start a server with minimization on, if you hit a page multiple times before greenscript is done compiling, you get an exception.

I'm using Play 1.2.4 and Greenscript 1.2.8, with minimization and compression enabled. We are using #{greenscript tags in main.html to load javascript and coffeescript.

The exception is

54423 [play-thread-2] ERROR com.greenscriptool.Minimizer - error compile coffee script file org.jcoffeescript.JCoffeeScriptCompileException: Error: too many ) on line 2 at org.jcoffeescript.JCoffeeScriptCompiler.compile(JCoffeeScriptCompiler.java:80) at com.greenscriptool.Minimizer.compileCoffee(Minimizer.java:487) at com.greenscriptool.Minimizer.compileCoffee(Minimizer.java:491) at com.greenscriptool.Minimizer.preprocess(Minimizer.java:805) at com.greenscriptool.Minimizer.merge(Minimizer.java:733) at com.greenscriptool.Minimizer.minimize(Minimizer.java:512) at com.greenscriptool.Minimizer.minimize_(Minimizer.java:568) at com.greenscriptool.Minimizer.process(Minimizer.java:359) at com.greenscriptool.RenderSession.output(RenderSession.java:141) at com.greenscriptool.IRenderSession$output.call(Unknown Source) at Template_1114$_runclosure1.doCall(output.html:12)

The actual parse error changes everytime, and if I disable minimization the coffeescript compiles just fine. My guess is that the problem lies on this line, in ClosureCompiler#compile

42 JSSourceFile file = JSSourceFile.fromInputStream("greenscript.js", new ReaderInputStream(r));

It seems to me that if this was called multiple times, then multiple threads would have a handle on the greescript.js file, and could be streaming to it simultaneously, resulting in a corrupt file. That's just a guess.

I'd be happy to take a crack at fixing it, but wanted to run it by you guys since this is new code to me.


Reply to this email directly or view it on GitHub: https://github.com/greenlaw110/greenscript/issues/38