figwheel-main

2022-02-04T21:27:34.663739Z

I'm trying to switch from lein-figwheel to figwheel-main. It now compiles my cljs using the settings in figwheel-main.edn and dev.cljs.edn. However, the websocket keeps disconnecting:

[goog.net.WebSocket] Opening the WebSocket on 
[goog.net.WebSocket] WebSocket opened on 
[goog.net.WebSocket] The WebSocket on  closed.
[goog.net.WebSocket] The WebSocket disconnected unexpectedly: undefined
How do I begin investigating this error? There's no error to be found anywhere that I've been able to spot.

2022-02-04T21:28:55.043959Z

Note that it seems to be able to connect, but then immediately disconnects.

2022-02-04T21:32:23.390089Z

This is using:

[com.bhauman/figwheel-main "0.2.16"]
[cider/piggieback "0.5.3"]
[nrepl "0.9.0"]

:repl-options {:nrepl-middleware [cider.piggieback/wrap-cljs-repl]}
In case that is of any use.

2022-02-04T21:33:15.377439Z

My figwheel-main.edn is nothing special:

{:open-url false
 :open-file-command "emacsclient"
 :watch-dirs ["src"]
 :css-dirs ["resources/public/css"]}

2022-02-04T21:33:30.225949Z

Same goes for dev.cljs.edn:

{:main no-adventur.ui.director
 :optimizations :none
 :pretty-print true
 :source-map true
 :asset-path "/js/compiled/out"
 :output-to "resources/public/js/compiled/adventur.js"
 :output-dir "resources/public/js/compiled/out"
 :foreign-libs [{:file "public/js/slip.js" :provides ["slip"]}]}

2022-02-04T21:36:56.294089Z

I'm starting figwheel in the repl with:

(figwheel.main/start "dev")

2022-02-04T21:37:27.439229Z

Which results in a happy compiler and a properly built set of js-files.

2022-02-04T21:39:12.200539Z

The ws-server gives:

HTTP/1.1 101 Switching Protocols

2022-02-04T21:40:02.279569Z

So it is able to reach it, but possibly not on the new protocol? Unexpected disconnects are pretty expected at this point. 🙃

2022-02-04T21:47:32.113819Z

I am now investigating dependency clashes.

2022-02-04T21:54:35.090869Z

I have now been able to fix this issue. I'll report back when I find which dependency was the culprit.

2022-02-05T08:18:59.404289Z

For posterity: The culprit turned out to be `[ring "1.7.1"]` . This collided with figwheel-main's `1.9.1` of the same library, and in turn jetty and jetty's websocket implementation.

2022-02-04T21:34:09.272029Z

Edit 30 minutes later: I have been able to fix this. Will report back when I figure out which dependency was the culprit. duckie

2022-02-04T22:10:46.745309Z

The culprit turned out to be [ring "1.7.1"] . This collided with figwheel-main's 1.9.1 of the same library, and in turn jetty and jetty's websocket implementation.

2022-02-04T22:23:10.146259Z

Going from 4 separate builds to a single figwheel-main build with 3 :extra-main-files 😍

2022-02-04T22:51:38.343549Z

Seems clashes with jetty are common here