This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
What is the meaning of this error in the browser console? This is from a simple ClojureScript project that was working yesterday, but seems to be broken after rebooting my laptop. If I run on the terminal I see this:
~/Repos/blog-index$ npx shadow-cljs watch app
shadow-cljs - config: /home/joseph/Repos/blog-index/shadow-cljs.edn
shadow-cljs - socket connect failed, server process dead?
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - HTTP server available at
shadow-cljs - server version: 2.28.10 running at
shadow-cljs - nREPL server started on port 44499
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
Exception in thread "async-dispatch-3" java.io.IOException: UT002002: Channel is closed
at io.undertow.websockets.core.WebSocketChannel.send(WebSocketChannel.java:354)
at io.undertow.websockets.core.WebSockets.sendBlockingInternal(WebSockets.java:992)
at io.undertow.websockets.core.WebSockets.sendBlockingInternal(WebSockets.java:986)
at io.undertow.websockets.core.WebSockets.sendTextBlocking(WebSockets.java:200)
at shadow.undertow$fn$reify__17649$fn__17773$state_machine__6617__auto____17812$fn__17815.invoke(undertow.clj:490)
at shadow.undertow$fn$reify__17649$fn__17773$state_machine__6617__auto____17812.invoke(undertow.clj:490)
at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:978)
at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:977)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:982)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:980)
at shadow.undertow$fn$reify__17649$fn__17773.invoke(undertow.clj:490)
at clojure.lang.AFn.run(AFn.java:22)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at clojure.core.async.impl.concurrent$counted_thread_factory$reify__484$fn__485.invoke(concurrent.clj:29)
at clojure.lang.AFn.run(AFn.java:22)
at java.base/java.lang.Thread.run(Thread.java:840)
[:app] Build completed. (175 files, 0 compiled, 0 warnings, 2.83s)
I don't have any source maps apparently:
It gave those source map errors even when it worked though
Perhaps I best just re-build my shadow project from scratch and copy+paste my code over
{:source-paths ["src/cljs"
;; "test/cljs"
]
:dependencies [[cljs-http "0.1.48"]
[reagent "1.2.0"]]
:dev-http {3010 "resources/public/"}
:builds {:app {:output-dir "resources/public/cljs/"
:asset-path "."
:target :browser
:modules {:main {:init-fn blog-index.index/main!}}}
;; :test {:target :node-test
;; :output-to "target/test.js"
;; :ns-regexp "-test$"}
}
;; :test {:runner :shadow.test-runner
;; :build-id "test"}
}
I commented the test bits since they are the only things I can remember changing since the last time it worked
ah OK I changed the asset path to cljs and I no-longer get the source map errors
thanks
same error about cljs-runtime though
well you now should know where your code fails? looks like you are supplying a wrong argument somewhere
ah OK for some reason I thought the errors were coming from cljs-runtime
cljs-runtime
is the folder where the debug files live, no meaning beyond that. they aren't even used and only exist there for source map purposes. if they are are used in any way thats a bug?
right I was clicking on the link in the firefox debugger and it was showing me some code that wasn't mine so I assumed cljs-runtime was some code
I am doing some stuff with array-map, just trying to understand what's wrong with it
(defn category-by-date
"sort the categories by the post with the most recent date within that category"
[cats]
(let [;; this looks at a single category to find the most recent post
get-biggest-post (fn [cat]
(apply max (map :date cat)))
;; this compares categories based on the most recent post from each
comp (fn [a b]
(> (get-biggest-post a) (get-biggest-post b)))
;; sort the categories
cats-sorted (sort-by val comp cats)]
;; convert back to map
(apply array-map cats-sorted)))
ah right that works!
OK I think that must be what I had yesterday but I swapped it out for array-map to ensure it would be ordered.
ordinary map does seem to be ordered though, despite the fact that the docs claim it's not
always treat maps as unordered. only happens to be a side-effect that array-map is ordered. maps by design are considered unordered
if you want order use some of the other non cljs.core implementations, or better yet don't use a map at all. there are some libs for this, but can't remember their names.
ah OK. I suppose it might not need to be a map as it's just gonna be converted to HTML
thanks anyway. probably saved me an hour of confusing myself
and it will teach me to commit to git more often