This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-20
Channels
- # announcements (1)
- # beginners (17)
- # calva (16)
- # cljfx (5)
- # clojure (94)
- # clojure-europe (1)
- # clojure-italy (2)
- # clojure-spec (4)
- # clojure-uk (1)
- # core-async (12)
- # datahike (3)
- # datomic (6)
- # depstar (4)
- # fulcro (30)
- # introduce-yourself (2)
- # malli (1)
- # off-topic (10)
- # re-frame (71)
- # shadow-cljs (15)
- # tools-deps (3)
- # xtdb (12)
not sure if this is the best place to post this…
something weird is happening with a combination of go
+ try
+ <!
+ :pre
here’s a minimal POC:
(defn inner-function
[{:keys [param]}]
{:pre [param]}
(println "in second function param=" param))
(defn outer-function> [{:keys [param]} req]
(clojure.core.async/go
(try
(println "before")
(clojure.core.async/<! (inner-function {:param param}))
(println "after ")
(catch Exception e
{:status 500
:error "Something happened"}))))
when calling outer-function>
with param nil
the precondition check will fail which is expected, but instead of returning an error message, there’s an infinite-loop that eventually crashes the service - printing:
before
before
before
...
indefinitely.
any ideas what is going on here?:pre/:post checks throw AssertionErrors, which will not be caught with "catch Exception", you'd need "catch Throwable"
thanks, I'll try that... I'll check if there's something that catches that throwable and keeps calling the outer function
The AssertionError can't be caught by the caller, because it is lost in the go block thread.
I’ve verified the loop is not coming from the caller of outer-function>
but definitely the core.async/go
is doing something funky.
i’ve added another print just before the go
and it’s only printed once, and then “before” is printed repeatedly.
so go
can’t handle a throwable thrown in its form? it just retries the form over and over again?
The exception handling on the clojure side of core.async a complete rewrite, and some fixes to the rewrite, and at the moment I am not aware of any bugs in it (there used to be all kinds of bugs that could cause things like infinite loops on exceptions). The clojurescript side is still buggy (it got the rewrite but not the bug fixes for the rewrite)
core.async 0.2.395
updated to 0.7.559 and issue seems to be fixed, thanks!