boot-clj / boot-cljs

Boot task to compile ClojureScript programs.
Eclipse Public License 1.0
177 stars 40 forks source link

"No ns form found ..." when using boot-reload #103

Open pandeiro opened 8 years ago

pandeiro commented 8 years ago

A very rare (maybe 5% or less of the time) bug I am hitting when using boot-cljs, boot-reload and multiple cljs.edn builds is the "No ns form found ...". It appears that the file that boot-reload is injecting prior to cljs compilation is empty when the (cljs ...) task tries to compile it:

Adding :require adzerk.boot-reload to main.cljs.edn...
Compiling ClojureScript...
? main.js
? tests.js
java.util.concurrent.ExecutionException: clojure.lang.ExceptionInfo: failed compiling file:/.boot/cache/tmp/app/1/-hru27v/boot/cljs/main12754.cljs {:file #object[java.io.File 0x48a25888 "/.boot/cache/tmp/app/1/-hru27v/boot/cljs/main12754.cljs"]}
             clojure.lang.ExceptionInfo: failed compiling file:/.boot/cache/tmp/app/1/-hru27v/boot/cljs/main12754.cljs
    data: {#object[clojure.lang.Keyword 0x2df8c34f ":file"] #object[java.io.File 0x48a25888 "/.boot/cache/tmp/app/1/-hru27v/boot/cljs/main12754.cljs"]}
             clojure.lang.ExceptionInfo: No ns form found in file:/.boot/cache/tmp/app/1/7o2s6s/adzerk/boot_reload.cljs at line 1 /.boot/cache/tmp/app/1/-hru27v/boot/cljs/main12754.cljs
    data: {#object[clojure.lang.Keyword 0x2df8c34f ":file"] "/.boot/cache/tmp/app/1/-hru27v/boot/cljs/main12754.cljs", #object[clojure.lang.Keyword 0x26a0e21e ":line"] 1, #object[clojure.lang.Keyword 0x5164ac91 ":column"] 1, #object[clojure.lang.Keyword 0x43da0d0f ":tag"] #object[clojure.lang.Keyword 0x25b13eda ":cljs/analysis-error"]}
               java.lang.AssertionError: No ns form found in file:/.boot/cache/tmp/app/1/7o2s6s/adzerk/boot_reload.cljs
                             cljs.analyzer$parse_ns$fn__2136.invoke  analyzer.cljc: 2706
                                      cljs.analyzer$parse_ns.invoke  analyzer.cljc: 2660
                                      cljs.analyzer$parse_ns.invoke  analyzer.cljc: 2651
                      cljs.analyzer$macro_autoload_ns_QMARK_.invoke  analyzer.cljc: 1782
cljs.analyzer$desugar_ns_specs$to_macro_specs__1835$fn__1838.invoke  analyzer.cljc: 1817
                                             clojure.core/filter/fn       core.clj: 2686
                                                                ...                     
                                                   clojure.core/seq       core.clj:  137
                                                clojure.core/map/fn       core.clj: 2616
                                                                ...                     
                                                   clojure.core/seq       core.clj:  137
                              cljs.analyzer$desugar_ns_specs.invoke  analyzer.cljc: 1825
                             cljs.analyzer$eval1863$fn__1865.invoke  analyzer.cljc: 1874
                                                                ...                     
                             cljs.analyzer$analyze_seq_STAR_.invoke  analyzer.cljc: 2368
                        cljs.analyzer$analyze_seq_STAR__wrap.invoke  analyzer.cljc: 2373
                                   cljs.analyzer$analyze_seq.invoke  analyzer.cljc: 2394
                                  cljs.analyzer$analyze_form.invoke  analyzer.cljc: 2503
                                 cljs.analyzer$analyze_STAR_.invoke  analyzer.cljc: 2550
                                       cljs.analyzer$analyze.invoke  analyzer.cljc: 2566
                   cljs.compiler$compile_file_STAR_$fn__3342.invoke  compiler.cljc: 1125
                                cljs.compiler$with_core_cljs.invoke  compiler.cljc: 1053
                            cljs.compiler$compile_file_STAR_.invoke  compiler.cljc: 1076
                         cljs.compiler$compile_file$fn__3383.invoke  compiler.cljc: 1237
                                  cljs.compiler$compile_file.invoke  compiler.cljc: 1216
                                  cljs.compiler$compile_root.invoke  compiler.cljc: 1291
                                           cljs.closure/compile-dir    closure.clj:  438
                                           cljs.closure/eval3772/fn    closure.clj:  478
                                         cljs.closure/eval3724/fn/G    closure.clj:  383
                                           cljs.closure/eval3785/fn    closure.clj:  492
                                         cljs.closure/eval3724/fn/G    closure.clj:  383
                          cljs.build.api/inputs/reify/compile-input        api.clj:  182
                                                clojure.core/map/fn       core.clj: 2624
                                                                ...                     
                                                   clojure.core/seq       core.clj:  137
                                                 clojure.core/apply       core.clj:  630
                                                clojure.core/mapcat       core.clj: 2660
                                                                ...                     
                               cljs.build.api/inputs/reify/-compile        api.clj:  186
                                                 cljs.closure/build    closure.clj: 1671
                                               cljs.build.api/build        api.clj:  219
                              adzerk.boot-cljs.impl/compile-cljs/fn       impl.clj:   63
                                 adzerk.boot-cljs.impl/compile-cljs       impl.clj:   62
                                                                ...                     
                                                 clojure.core/apply       core.clj:  630
                                              boot.pod/eval-fn-call        pod.clj:  184
                                                  boot.pod/call-in*        pod.clj:  191
                                                                ...                     
                                                  boot.pod/call-in*        pod.clj:  194
                                           adzerk.boot-cljs/compile  boot_cljs.clj:   75
                                      adzerk.boot-cljs/compile-1/fn  boot_cljs.clj:  138
                                clojure.core/binding-conveyor-fn/fn       core.clj: 1916

Could this be related to some race condition with the cljs task? The low reproducibility suggests something like that to me, prior to going into the impl.cljs and inspecting.

Deraen commented 8 years ago

Need more info. I have not seen this.

Deraen commented 8 years ago

@pandeiro Are you still seeing this? I'm going to close this if there's no more info.

wagjo commented 8 years ago

I'm seeing it too. Exception is:

java.lang.AssertionError: No ns form found in file:/home/wagjo/.boot/cache/tmp/home/proj/p3q/-x24pa9/adzerk/boot_cljs_repl.cljs
          cljs.analyzer$parse_ns$fn__2009.invoke  analyzer.cljc: 2751
             cljs.analyzer$parse_ns.invokeStatic  analyzer.cljc: 2706
                   cljs.analyzer$parse_ns.invoke  analyzer.cljc: 2687
             cljs.analyzer$parse_ns.invokeStatic  analyzer.cljc: 2697
cljs.closure/find-cljs-dependencies/invokeStatic    closure.clj:  691
cljs.closure/add-dependency-sources/invokeStatic    closure.clj:  749
                 cljs.closure/build/invokeStatic    closure.clj: 1892
               cljs.build.api/build/invokeStatic        api.clj:  206
 adzerk.boot-cljs.impl/compile-cljs/invokeStatic       impl.clj:   76
              adzerk.boot-cljs.impl/compile-cljs       impl.clj:   66
                                             ...                     
                 clojure.core/apply/invokeStatic       core.clj:  646
                              clojure.core/apply       core.clj:  641
                           boot.pod/eval-fn-call        pod.clj:  294
                               boot.pod/call-in*        pod.clj:  315
                                             ...                     
                               boot.pod/call-in*        pod.clj:  318
                        adzerk.boot-cljs/compile  boot_cljs.clj:   71
                   adzerk.boot-cljs/compile-1/fn  boot_cljs.clj:  126
             clojure.core/binding-conveyor-fn/fn       core.clj: 1916

Dependencies

   [adzerk/boot-cljs "1.7.228-1" :scope "test"]
   [adzerk/boot-cljs-repl "0.3.0" :scope "test"]
   [adzerk/boot-reload "0.4.4" :scope "test"]

task we're running

  (comp
   (system :sys #'foo.standalone/system :auto-start true)
   (watch)
   (less :source-map true :compression false :inline-javascript true)
   (reload :on-jsload 'foo.app/fig-reload)
   (cljs-repl)
   (cljs :source-map true))
pandeiro commented 8 years ago

@Deraen This issue still exists for us; its infrequency means it's not a big deal, but we still get failed tests now and then because of it. And now it has been seen by @wagjo as well. Not sure what should / can be done, but if there's something else I can do, please let me know.

Deraen commented 8 years ago

I'm yet to see this myself.

A start would be to have a test project where you can reproduce this so that I could try to reproduce this.

pandeiro commented 8 years ago

@wagjo Are you able to reproduce this reliably? How frequently do you see this? It would be great if we could create a sample repo for Juho to look at.

wagjo commented 8 years ago

Nope, I only get this error in about 5% of runs.

mjmeintjes commented 8 years ago

I think I might be getting the same bug - on Travis CI sometimes the build fails after successful run, even if nothing changed. E.g. https://travis-ci.org/mjmeintjes/boot-react-native/builds/109811514 vs https://travis-ci.org/mjmeintjes/boot-react-native/builds/109810642 (same source code, just merged branch).

Deraen commented 7 years ago

I think there is a chance that recent change in Boot-reload 0.5.0 might have fixed this: https://github.com/adzerk-oss/boot-reload/commit/9f430b2aa9acd06d45ae7e72ade569fb178a6c21

Deraen commented 7 years ago

I have not seen this myself in 5 months and I don't recall anyone at work mentioning this since the change, so I'll presume this was fixed.

Deraen commented 7 years ago

Except Boot-cljs-repl still uses the old way to inject code to the build: https://github.com/adzerk-oss/boot-cljs-repl/blob/master/src/adzerk/boot_cljs_repl.clj#L168