bhauman / figwheel-repl

Figwheel REPL provides a stable multiplexing REPL for ClojureScript
45 stars 11 forks source link

cljs-repl fails to start #7

Closed dimovich closed 4 years ago

dimovich commented 5 years ago

Running on Ubuntu 16.04, with Firefox 68.0.1 and Chrome 75.0.3770.142.

Trying to start this project

clj -A:figwheel

After successful compilation the browser automatically opens up and the page is loaded, but the cljs-repl doesn't start in the console.

Here is the failing trace (notice on this line that figwheel.repl/setup returns {25535 #, 37797 #, 11110 #, ...}).

Here is a normal trace where the cljs-repl starts normally (notice that figwheel.repl/setup returns true). In this case I have the browser already opened so figwheel just opens a new tab.

I noticed that if I wrap this function call to open the browser in a future, everything works as expected, and the cljs-repl starts in the console. Here is the future trace. Tested it with figwheel-main 0.2.0 and 0.2.3, with both closed and opened browser, Firefox and Chrome.

bhauman commented 5 years ago

figwheel-main 0.2.3

Should fix this problem. Make sure you clean and recompile.

On Sun, Jul 28, 2019 at 5:21 AM, dimovich notifications@github.com wrote:

Running on Ubuntu 16.04, with Firefox 68.0.1 and Chrome 75.0.3770.142.

Trying to start this project

clj -A:figwheel

After successful compilation the browser automatically opens up and the page is loaded, but the cljs-repl doesn't start in the console.

Here is the failing trace (notice on this line that figwheel.repl/setup returns {25535 #, 37797 #, 11110 #, ...}).

Here is a normal trace where the cljs-repl starts normally (notice that figwheel.repl/setup returns true). In this case I have the browser already opened so figwheel just opens a new tab.

I noticed that if I wrap this function call to open the browser in a future, everything works as expected, and the cljs-repl starts in the console. Tested it with figwheel-main 0.2.0 and 0.2.3, with both closed browser and opened browser, Firefox and Chrome.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

dimovich commented 5 years ago

Cleaned up .m2, .cpcache and js/out. Switched to figwheel-main 0.2.3. Still having the issue.

bhauman commented 5 years ago

Alrighty it looks like we need to put it on another thread and maybe add a configurable sleep.

On Sun, Jul 28, 2019 at 8:23 AM, dimovich notifications@github.com wrote:

Cleaned up .m2, .cpcache and js/out. Switched to figwheel-main 0.2.3. Still having the issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

bhauman commented 5 years ago

I would love for you to try these things out and See which one works most reliably.

On Sun, Jul 28, 2019 at 8:23 AM, dimovich notifications@github.com wrote:

Cleaned up .m2, .cpcache and js/out. Switched to figwheel-main 0.2.3. Still having the issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

dimovich commented 5 years ago

Alright, will look into it.

dimovich commented 5 years ago

@bhauman Some thoughts:

What should the option be called? :open-url-time-ms :open-url-wait-ms ...?

Should we always launch the browser in a separate thread or only when the new option is specified? If for most people it works fine without a separate thread then it would be ok leaving it as is. But always launching in a separate thread shouldn't cause any issues.

Thread vs. future The thread pool which backs Clojure futures does not use daemon threads. So in order to prevent the browser from blocking the main thread, we need to use Thread.

Here is one possible code change.

We also need to add the new option to figwheel-main.

dimovich commented 5 years ago

Eventually, if more people will bump into this issue, we can set to always launch the browser in a separate thread. For now, it would be safer to leave the default behavior, and use a separate thread only when the :open-url-wait-ms option is specified.

LeifAndersen commented 3 years ago

For what its worth, I also seem to be having this problem. With clojurescript 1.10.741 on ubuntu 18.04.

dimovich commented 3 years ago

Hello @LeifAndersen

Have you tried using the new :open-url-wait-ms option? In your dev.cljs.edn add:

^{:open-url-wait-ms 3000
  ;; other figwheel opts}

Another thing you could try is upgrading your deps. ClojureScript to 1.10.773 and figwheel-main to 0.2.12

LeifAndersen commented 3 years ago

Have you tried using the new :open-url-wait-ms option?

Yes I have, and the repl still doesn't start.

Another thing you could try is upgrading your deps. ClojureScript to 1.10.773 and figwheel-main to 0.2.12

Unfortunately I can't use Clojurescript 1.10.773 due to a regression in that release. But if I could then the repl does start.

dimovich commented 3 years ago

Could you please post your deps.edn and figwheel config?

LeifAndersen commented 3 years ago

Absolutely. Here is my deps.edn:

{:deps {org.clojure/clojure {:mvn/version "1.10.1"}
        org.clojure/clojurescript {:mvn/version "1.10.741"}
        org.clojure/core.match {:mvn/version "1.0.0"}
        org.clojure/tools.reader {:mvn/version "1.3.3"}
        reagent {:mvn/version "0.10.0" :exclusions [cljsjs/react cljsjs/react-dom]}
        com.cognitect/transit-cljs {:mvn/version "0.8.264"}
        alandipert/storage-atom {:mvn/version "2.0.1"}
        com.bhauman/figwheel-main {:mvn/version "0.2.12"}
        com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}}
 :aliases {:fig {:main-opts ["-m" "figwheel.main" "--build" "dev" "--repl"]}
           :package {:main-opts ["-m" "figwheel.main" "--build-once" "prod"]}}
 :paths ["src" "test" "target" "resources" "env/dev" "env/prod"]}

And here is my dev.cljs.edn file:

^{:auto-bundle :webpack
  :watch-dirs ["src" "test" "env/dev"]
  :auto-testing true
  :open-url-wait-ms 3000}
{:main interactive-syntax.dev
 ;;:deps-command "npm"
 :bundle-cmd
 {:none ["npx" "webpack" "--mode=development" "src/js/bundle.js" :output-to
         "--output-path" :final-output-dir
         "--output-filename" :final-output-filename]
  :default ["npx" "webpack" "--mode=production" "src/js/bundle.js" :output-to
            "--output-path" :final-output-dir
            "--output-filename" :final-output-filename]}}
dimovich commented 3 years ago

@LeifAndersen can confirm that cljs-repl doesn't connect with ClojureScript 1.10.741, but works fine with 1.10.773. You are using the webpack bundler, and https://figwheel.org/docs/npm.html mentions you need at least 1.10.773.

LeifAndersen commented 3 years ago

Oh, I didn't notice that figwheel required 1.10.773 (since the :bundle target was added in 1.10.741). May I ask why that limitation is there?

dimovich commented 3 years ago

@LeifAndersen Maybe you can find more info here https://github.com/bhauman/figwheel-main/issues/247

I've tried doing some tracing for cljs 1.10.773 and 1.10.441 and the only difference seems that figwheel.repl/connections-available keeps returning an empy list for 1.10.441, even though figwheel.repl/*connections* is not empty.