Fork me on GitHub
#hoplon
<
2016-01-31
>
levitanong15:01:17

@laforge49, @flyboarder, I figured out what the problem was. It wasn’t with my code! (refresher: My problem is the thing with *session* not working as expected) Turns out the problematic bit was the handler, as generated by lein new hoplon-castra.

(def app
  (-> app-routes
      (d/wrap-defaults d/api-defaults)
      (castra/wrap-castra-session "a 16-byte secret")
      (castra/wrap-castra ’thingy.api)))
If I rearrange it by moving the form up to the top like so:
(def app
  (-> app-routes
      (castra/wrap-castra ’thingy.api)
      (d/wrap-defaults d/api-defaults)
      (castra/wrap-castra-session "a 16-byte secret")))
*session* suddenly works. Which is great, except I don’t exactly know why this is causing the screwup. Do you guys have any idea?

flyboarder15:01:16

Could be something else interacting with session, in the stack

flyboarder15:01:47

I have all my Castra forms up top and wrap defaults last

levitanong15:01:59

thing is, when i apply that to the demos

levitanong15:01:04

sessions stop working

levitanong15:01:14

i mean, when i use the arrangement as in the hoplon castra template, the demo breaks

levitanong15:01:24

specifically, castra-chat

flyboarder16:01:10

That may be something we need to fix in the template, I'm not sure who usually works on that but I'm sure they are open to a PR

levitanong16:01:15

@flyboarder: Do you think I should file an issue somewhere, like the hoplon castra repo? After all, you seem to think the order shouldn’t matter much. Or perhaps I should tag micha or alan?

micha16:01:21

@levitanong: the order in which middleware are applied definitely matters

laforge4916:01:28

On advice from micha,, I have this which works: (-> app-routes (castra/wrap-castra 'castra-notify-chat.chat-api 'castra-notify-chat.user-api 'notify.notification-api) (castra/wrap-castra-session "a 16-byte secret") (d/wrap-defaults d/api-defaults))) So like @flyboarder I have defaults on the bottom. And like @levitanong 's arrangement that works, I have wrap castra thingie on top. The actual problem is that the template is backwards because -> reverses the order.

micha16:01:46

because it's a pipeline, each layer adding information for the subsequent layers to use

micha16:01:40

(-> foo bar baz) ; is the same as:
(baz (bar foo))

micha16:01:49

so the order definitely matters

laforge4916:01:07

So where do I file the issue? simple_smile

levitanong16:01:21

yay I’m not crazy!

micha16:01:45

i thought i fixed the lein template, no?

laforge4916:01:03

doesn't look like it.

micha16:01:11

i think i didn't have permission to push it to clojars

micha16:01:21

but the git repo should be fixed

laforge4916:01:26

ah yes that was the case.

laforge4916:01:39

Doesn't help newbies.

laforge4916:01:46

It's like your alpha11. Lots of folk are just going to do a boot show -u and upgrade to alpha11. It is a trap for the greater community.

micha16:01:59

yeah i'll fix that now

laforge4916:01:00

It's those little things that end up biting you where the sun don't shine. 😄

laforge4916:01:43

Being too busy may be virtuous, but self management is the greater virtue.

micha16:01:20

@levitanong: excellent issue (#78), thanks for the clear repro case

micha16:01:54

very easy to test now simple_smile

levitanong16:01:29

Hurrah! Just doing my part, @micha simple_smile

micha17:01:10

this fix also keeps the behavior of https://github.com/hoplon/hoplon/pull/72, so the memory leak is still avoided in those situations

levitanong18:01:00

Hurrah! You the man, @micha

micha18:01:25

it's a pleasure to fix bugs when there are awesome minimal repro cases

dm318:01:07

(when-not [*preserve..*] ..) <- always true

micha18:01:37

what is going on there

micha18:01:26

how is that not causing a memory leak with the #72 test?

micha18:01:47

i can see GC happening no problem

micha18:01:02

hm i think i may have been reading the profiler incorrectly

levitanong19:01:15

^ was about to ask if you were going to bump the version to 13 😛

micha19:01:00

there we go