taoensso / sente

Realtime web comms library for Clojure/Script
https://www.taoensso.com/sente
Eclipse Public License 1.0
1.73k stars 193 forks source link

Sente 1.19.0 Encore version can cause build issues with shadow-cljs #433

Closed abishek closed 11 months ago

abishek commented 11 months ago

I am trying to use sente inside a node target for my project. To start, I am trying to use the example given in https://github.com/theasp/sente-nodejs-example/blob/master/src-client/example/node.cljs with sente 1.19.0 for my project. But when I try to run the compile, I get this error.

shadow-cljs - config: /Users/abishek/Projects/sente-node-client/shadow-cljs.edn
shadow-cljs - starting via "clojure"
shadow-cljs - server version: 2.24.1 running at http://localhost:9630
shadow-cljs - nREPL server started on port 59847
shadow-cljs - watching build :client
[:client] Configuring build.
[:client] Compiling ...
[:client] Build failure:
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/abishek/.m2/repository/com/taoensso/encore/3.62.0/encore-3.62.0.jar!/taoensso/encore.cljc:999:3
--------------------------------------------------------------------------------
 996 | 
 997 |   {:added "v3.31.0 (2022-10-27)"}
 998 |   [fixtures-map]
 999 |   (have? map?                         fixtures-map)
---------^----------------------------------------------------------------------
Encountered error when macroexpanding taoensso.encore/have?.
IllegalArgumentException: Not a file: jar:file:/Users/abishek/.m2/repository/com/taoensso/encore/3.62.0/encore-3.62.0.jar!/taoensso/encore.cljc
        clojure.java.io/fn--11513 (io.clj:61)
        clojure.java.io/fn--11513 (io.clj:44)
        clojure.java.io/fn--11487/G--11469--11492 (io.clj:35)
        clojure.java.io/file (io.clj:424)
        clojure.java.io/file (io.clj:418)
        taoensso.truss.impl/get-source (impl.cljc:64)
        taoensso.truss.impl/get-source (impl.cljc:56)
        taoensso.truss/have? (truss.cljc:62)
        taoensso.truss/have? (truss.cljc:54)
        clojure.core/apply (core.clj:671)
        clojure.core/apply (core.clj:662)
        cljs.analyzer/macroexpand-1*/fn--3704 (analyzer.cljc:4025)
        cljs.analyzer/macroexpand-1* (analyzer.cljc:4023)
        cljs.analyzer/macroexpand-1* (analyzer.cljc:4010)
        cljs.analyzer/macroexpand-1 (analyzer.cljc:4074)
        cljs.analyzer/macroexpand-1 (analyzer.cljc:4070)
        cljs.analyzer/analyze-seq (analyzer.cljc:4107)
        cljs.analyzer/analyze-seq (analyzer.cljc:4087)
        cljs.analyzer/analyze-form (analyzer.cljc:4296)
        cljs.analyzer/analyze-form (analyzer.cljc:4293)
        cljs.analyzer/analyze* (analyzer.cljc:4349)
        cljs.analyzer/analyze* (analyzer.cljc:4341)
        cljs.analyzer/analyze (analyzer.cljc:4369)
        cljs.analyzer/analyze (analyzer.cljc:4352)
        cljs.analyzer/analyze (analyzer.cljc:4362)
        cljs.analyzer/analyze (analyzer.cljc:4352)
        cljs.analyzer/analyze (analyzer.cljc:4360)
        cljs.analyzer/analyze (analyzer.cljc:4352)
        cljs.analyzer/analyze-do-statements*/fn--2974 (analyzer.cljc:2349)
        clojure.core/mapv/fn--8535 (core.clj:6979)
        clojure.lang.ArrayChunk.reduce (ArrayChunk.java:58)
        clojure.core.protocols/fn--8244 (protocols.clj:136)
        clojure.core.protocols/fn--8244 (protocols.clj:124)
        clojure.core.protocols/fn--8204/G--8199--8213 (protocols.clj:19)
        clojure.core.protocols/seq-reduce (protocols.clj:31)
        clojure.core.protocols/fn--8234 (protocols.clj:75)
        clojure.core.protocols/fn--8234 (protocols.clj:75)
        clojure.core.protocols/fn--8178/G--8173--8191 (protocols.clj:13)
        clojure.core/reduce (core.clj:6886)
        clojure.core/mapv (core.clj:6970)
        clojure.core/mapv (core.clj:6970)
        cljs.analyzer/analyze-do-statements* (analyzer.cljc:2349)
        cljs.analyzer/analyze-do-statements* (analyzer.cljc:2348)
        cljs.analyzer/analyze-do-statements (analyzer.cljc:2352)
        cljs.analyzer/analyze-do-statements (analyzer.cljc:2351)
        cljs.analyzer/fn--2979 (analyzer.cljc:2356)
        cljs.analyzer/fn--2979 (analyzer.cljc:2354)
        clojure.lang.MultiFn.invoke (MultiFn.java:252)
        cljs.analyzer/analyze-seq* (analyzer.cljc:4080)
        cljs.analyzer/analyze-seq* (analyzer.cljc:4078)
        cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:4085)
        cljs.analyzer/analyze-seq*-wrap (analyzer.cljc:4083)
        cljs.analyzer/analyze-seq (analyzer.cljc:4109)
        cljs.analyzer/analyze-seq (analyzer.cljc:4087)
        cljs.analyzer/analyze-form (analyzer.cljc:4296)
        cljs.analyzer/analyze-form (analyzer.cljc:4293)
        cljs.analyzer/analyze* (analyzer.cljc:4349)
        cljs.analyzer/analyze* (analyzer.cljc:4341)
        cljs.analyzer/analyze (analyzer.cljc:4369)
        cljs.analyzer/analyze (analyzer.cljc:4352)
        cljs.analyzer/analyze (analyzer.cljc:4362)
        cljs.analyzer/analyze (analyzer.cljc:4352)
        cljs.analyzer/analyze (analyzer.cljc:4360)
        cljs.analyzer/analyze (analyzer.cljc:4352)
        cljs.analyzer/analyze-fn-method-body (analyzer.cljc:2147)
        cljs.analyzer/analyze-fn-method-body (analyzer.cljc:2145)
        cljs.analyzer/analyze-fn-method (analyzer.cljc:2169)
        cljs.analyzer/analyze-fn-method (analyzer.cljc:2149)
        cljs.analyzer/analyze-fn-methods-pass2*/fn--2921 (analyzer.cljc:2206)
        clojure.core/mapv/fn--8535 (core.clj:6979)
        clojure.core.protocols/fn--8249 (protocols.clj:168)
        clojure.core.protocols/fn--8249 (protocols.clj:124)
        clojure.core.protocols/fn--8204/G--8199--8213 (protocols.clj:19)
        clojure.core.protocols/seq-reduce (protocols.clj:31)
        clojure.core.protocols/fn--8234 (protocols.clj:75)
        clojure.core.protocols/fn--8234 (protocols.clj:75)
        clojure.core.protocols/fn--8178/G--8173--8191 (protocols.clj:13)
        clojure.core/reduce (core.clj:6886)
        clojure.core/mapv (core.clj:6970)
        clojure.core/mapv (core.clj:6970)

--------------------------------------------------------------------------------
1000 |   ;; (have? [:ks<= #{:before :after}] fixtures-map)
1001 | 
1002 |   #?(:cljs fixtures-map ; Cljs supports a map with {:keys [before after]}
1003 |      :clj ; Clj wants a fn
--------------------------------------------------------------------------------

My deps.edn is simple

{:paths ["src"]
 :deps {org.clojure/clojure       {:mvn/version "1.11.1"}
        org.clojure/clojurescript {:mvn/version "1.11.60"}
        org.clojure/core.async    {:mvn/version "1.6.673"}
        thheller/shadow-cljs      {:mvn/version "2.24.1"}
        com.taoensso/timbre       {:mvn/version "6.2.1"}
        com.taoensso/sente        {:mvn/version "1.19.0"}}}

And so is my package.json

{
    "devDependencies": {
        "shadow-cljs": "^2.24.1",
        "source-map-support": "^0.5.21",
        "watch": "0.13.0"
    },
    "dependencies": {
        "websocket": "^1.0.34"
    }
}

Lastly, my shadow-cljs.edn is

{:deps true
 :builds {:client {:target :node-script
                   :output-to "target/main.js"
                   :main rohabini.sente-node-client.main/main!}}}

I tried deleting the encore folder from $HOME/.m2 just in case there was a download issue. But it downloads again and I get the same error. The only difference I am seeing is that I am trying to use this in a node-script target. I have not tried running the example as is. How do I debug this? Thanks!

ptaoussanis commented 11 months ago

@abishek Hi Abishek, sorry about that - this is a known issue with the current version of Encore being used by Sente.

To work around the problem, please add a com.taoensso/encore {:mvn/version "3.62.1"} dependency before any other com.taoensso deps.

Will aim to put out a new Sente release shortly that includes the updated dependency.

ptaoussanis commented 11 months ago

I've just released v1.19.1 that automatically includes an updated Encore dependency - you can also just use that instead 👍

Apologies for the trouble.