Fork me on GitHub
#reitit
<
2019-11-29
>
lispyclouds12:11:05

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?

valerauko13:11:05

are you using any middleware?

lispyclouds13:11:53

nope, just put this in the example code and tried running it

lispyclouds13:11:40

that uses some interceptors i think

valerauko14:11:03

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.

lispyclouds14:11:57

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?

valerauko14:11:20

just in case, try derefing the let-flow in the handler? @(d/let-flow ,,,)

lispyclouds15:11:35

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"
}

lispyclouds15:11:46

dont see a stacktrace too

lispyclouds15:11:35

it was my bad, the + was causing issues with the str params, fixed by changing + to str

lispyclouds15:11:55

with the deref, i get the response as expected

lispyclouds15:11:59

now it works! the exception was the issue 😕

lispyclouds15:11:40

not sure why it just hung when it had the error

valerauko15:11:28

could it be that aleph just uses nil if the deferred is rejected? iirc the "no response" thing happens if you return nil

ikitommi09:12:43

@U7ERLH6JX there is a new version of sieppari, which had a issue with async errors. Will update the dep and the examples soon.

lispyclouds09:12:32

Ah okay. Thanks!

ikitommi09:12:34

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

ikitommi09:12:31

those add 7sec to startuptime, so not loaded by default.

ikitommi09:12:25

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

valerauko10:12:46

wait what 7 sec?

ikitommi10:12:34

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.

ikitommi10:12:42

this is kinda bad for newbie experience (to wait the reitit-http example app to load 12sec into the repl). reitit-ring does use those heavy libs, so much faster to load.

ikitommi10:12:04

not effecting runtime perf