This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-29
Channels
- # adventofcode (11)
- # aws (2)
- # bangalore-clj (8)
- # beginners (92)
- # boot (2)
- # calva (26)
- # cider (1)
- # clj-kondo (4)
- # cljs-dev (4)
- # clojure (54)
- # clojure-berlin (5)
- # clojure-houston (6)
- # clojure-italy (12)
- # clojure-nl (7)
- # clojure-uk (39)
- # clojurescript (12)
- # clojutre (6)
- # cryogen (1)
- # cursive (15)
- # datomic (11)
- # duct (1)
- # events (5)
- # fulcro (14)
- # jackdaw (1)
- # joker (2)
- # malli (15)
- # mental-health (1)
- # off-topic (35)
- # reagent (2)
- # reitit (24)
- # rewrite-clj (3)
- # shadow-cljs (19)
- # vim (11)
Hello, I'm trying to get reitit running within aleph and have been following the example here: https://github.com/metosin/reitit/blob/master/examples/http-swagger/src/example/server.clj
I need to run some handlers in an existing app which uses manifold's let-flow
: https://github.com/ztellman/manifold/blob/master/docs/deferred.md#let-flow
for this I added another route to the example code like this:
["/let-flow"
{:get {:swagger {:tags ["let-flow"]}
:summary "let-flow stuff"
:parameters {:query (s/keys :req-un [::a ::b])}
:responses {200 {:body any?}}
:handler (fn [{{{:keys [a b]} :query} :parameters}]
(d/let-flow [x 4
y 5]
{:status 200
:body (+ a b x y)}))}}]
This just doesnt seem to return when the request hits this. The handler is invoked properly but there is no response. Manifold's chain seems to work fine. What could be the issue?nope, just put this in the example code and tried running it
that uses some interceptors i think
aleph itself can handle deferred returned from the handler (which let-flow is), but interceptors/middleware generally can't.
i don't return deferred from handlers, but aleph.http/wrap-ring-async-handler
is mentioned in the docs. https://github.com/ztellman/aleph#http
not sure how that works with interceptors though.
There is manifold's chain here in https://github.com/metosin/reitit/blob/master/examples/http-swagger/src/example/server.clj#L67 that seems to work fine. I tried pretty much the same thing?
with the deref its a weird:
HTTP/1.1 500 Internal Server Error
Connection: Keep-Alive
Content-Type: application/json; charset=utf-8
Date: Fri, 29 Nov 2019 15:09:57 GMT
Server: Aleph/0.4.6
transfer-encoding: chunked
{
"class": "java.lang.ClassCastException",
"type": "exception"
}
dont see a stacktrace too
it was my bad, the + was causing issues with the str params, fixed by changing + to str
with the deref, i get the response as expected
now it works! the exception was the issue 😕
not sure why it just hung when it had the error
could it be that aleph just uses nil if the deferred is rejected? iirc the "no response" thing happens if you return nil
@U7ERLH6JX there is a new version of sieppari, which had a issue with async errors. Will update the dep and the examples soon.
Ah okay. Thanks!
New version of sieppari will not support manifold & core.async oob. To add support, one needs to manually require sieppari.async.manifold
or sieppari.async.core-async
might need to require both on reitit.http
not to break existing clients. But will make the choosing of async impl explicit for reitit 1.0.0
for all the classes to compile. So, repl startup and server startup if not fully AOTd. Clojure Core Team might be working on local AOT-cache to solve this.