Fork me on GitHub
#figwheel-main
<
2021-12-13
>
pataprogramming18:12:54

I've been pulling my hair out trying to get figwheel-main working with a fairly complex project. It's a sort of template project that I use when I want to put together a full-stack SPA. It's closely tuned to the way I like to structure things (component and system using duct-style routes, sente websockets, re-frame). I had it working about a year ago with lein-figwheel, but I've had to do a fair amount of fixing things up to get all the dependencies up-to-date. It uses http-kit for the main server (with the sente websockets) and lets figwheel do its own thing on its own port. The old figwheel was being problematic, so I ripped it out and have been trying to get figwheel-main integrated. It successfully compiles the CLJS, the figwheel Jetty server appears to initialize, but upon receiving a client request it returns an empty response. I've removed CIDER from the equation, and am just trying to spin up the app from command-line using lein. I've successfully set up an empty figwheel-main project with lein in a parallel directory, and can connect to it in the browser. (In fact, if the SPA is running, it will happily connect to that figwheel-main server, though that is, of course, completely useless. It does establish that whatever is going on, it's something in my project and not some weird networking or browser thing. Log attached in thread.

pataprogramming18:12:27

Any suggestions for next troubleshooting steps will be MUCH appreciated.

pataprogramming19:12:42

% curl -vv 
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 9500 (#0)
> GET /figwheel-connect HTTP/1.1
> Host: localhost:9500
> User-Agent: curl/7.64.1
> Accept: */*
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
* Closing connection 0

pataprogramming20:12:04

Got it! It turns out that it was a dependency conflict between ring 1.9.4, which pulls in

[ring/ring-jetty-adapter "1.9.4"]
     [org.eclipse.jetty/jetty-server "9.4.42.v20210604"]
       [org.eclipse.jetty/jetty-io "9.4.42.v20210604"]
and figwheel-main 0.2.15, which pulls in
[org.eclipse.jetty.websocket/websocket-server "9.4.36.v20210114"]
     [org.eclipse.jetty.websocket/websocket-client "9.4.36.v20210114"]
       [org.eclipse.jetty/jetty-client "9.4.36.v20210114"]
     [org.eclipse.jetty.websocket/websocket-common "9.4.36.v20210114"]
       [org.eclipse.jetty/jetty-util "9.4.36.v20210114"]
     [org.eclipse.jetty/jetty-http "9.4.36.v20210114"]
     [org.eclipse.jetty/jetty-servlet "9.4.36.v20210114"]
       [org.eclipse.jetty/jetty-security "9.4.36.v20210114"]
       [org.eclipse.jetty/jetty-util-ajax "9.4.36.v20210114"]
   [org.eclipse.jetty.websocket/websocket-servlet "9.4.36.v20210114"]
     [org.eclipse.jetty.websocket/websocket-api "9.4.36.v20210114"]

pataprogramming20:12:26

Resolved for now by changing the dev dependency to

[com.bhauman/figwheel-main "0.2.15"
 :exclusions [org.eclipse.jetty.websocket/websocket-server
              org.eclipse.jetty/websocket/websocket-servlet]]
[org.eclipse.jetty.websocket/websocket-server "9.4.42.v20210604"]
[org.eclipse.jetty.websocket/websocket-servlet "9.4.42.v20210604"]

pataprogramming21:12:11

Had to add the new hooks for figwheel-main to re-render the re-frame stuff, but everything is now updating like butter.

🎉 3