Fork me on GitHub
#fulcro
<
2020-04-15
>
folcon02:04:21

I had someone ask me about what progress was on getting things working on heroku. So to anyone else interested, it’s up and I’ve put together some instructions =)… https://folcon.github.io/post/2020-04-12-Fulcro-on-Heroku/ Let me know if you hit a snag I haven’t covered and I’ll add it ^_^…

👍 12
codonnell02:04:14

Thanks for writing this! Nice to see a working non-docker approach to heroku deployment. 🙂 I think if you build your uberjar after compiling shadow-cljs, then your compiled javascript should be in the uberjar and you can omit the :files "public/resources" addition.

folcon03:04:58

You’re not wrong, but I initially did it the other way around =)… Hence really noticing the files missing and adding the entry to problems. Things like that are really annoying to debug I find and can trip beginners up, so I try and document things like that =)… That’s a good reminder to add explanations though, so thanks!

👍 4
Piotr Roterski12:04:08

@U0JUM502E nice work :thumbsup: have you managed to host it reliably on free 512mb dynos or you needed to use bigger ones?

folcon12:04:33

It’s been running perfectly fine on standard-1X, just need to test it on a hobby tier, just in case anyone want’s to run it on that…

folcon12:04:28

You might need to restart it once or twice, but in general it’s very doable unless you’re doing something crazy to run on the smaller tiers for a while =)…

folcon12:04:56

Yep, works fine. Not sure why people think it needs a Standard-2X? It certainly will work better with one, the jvm loves its memory after all…

Piotr Roterski12:04:35

when I tried it on 512mb dyno it used to exceed memory and crash pretty often during startup but I guess for development you can live with restarting it few times until it works

Piotr Roterski12:04:14

anyway, it might be something worth mentioning in your post so your readers are aware of this issue/limitation 🙌

folcon12:04:58

Just to clarify, it’s not dev only 😃, I can and have run jvm builds on the hobby tier for fun little projects. You’ve got to pay attention to it, but if it’s a free offering you can reliably get it running without big memory/crashing problems. Obviously if people are paying good money, you need to splash out, but it’s very possible to run a lean jvm =)… However, that’s a good point, I really should add a note at the bottom.

Piotr Roterski12:04:25

agreed 😌 i just wondered if you use any jvm tricks to reduce memory footprint or you just stick to "restarting until it works" ™️ for fulcro-template based project

folcon13:04:15

Hmm, there’s some jvm stuff, but I don’t have it all in one place… The easiest general purpose answer is to profile and go from there? Let me have a think about if there’s other simple stuff that can be done =)…

folcon13:04:20

One question to people reading it, how does it read? Understandable etc? Style niceish or annoying? I really prefer writing reasonably casually, but I want to make sure it’s understandable and not just a rambling hard to understand mess =)…

folcon22:04:52

@UHA0AQZ2M, this may be pretty obvious but, the only the only two other things I can think of that aren’t really just profile are to try using alternative jvms/gc’s? Default openjdk14 is pretty good on heroku in my experience… Shenandoah is also worth a go…

Piotr Roterski18:04:54

@U0JUM502E I have no experience dealing with jvm optimisation so I appreciate even obvious advices 🙂 it might be worth giving a try to alternative buildpacks like you say

folcon18:04:02

You don’t need alternative buildpacks to do that =)… I added some more details to the bottom of my post because you asked, so it’s explained more there, but in short, you can use system.properties to set your jvm version and just need to know what flags you need… Post some initial peak load, I got mine running at a reasonable mem atm =)… Between 332-394mb, on a hobby dyno not the best, but I’m happy with it =)…

Piotr Roterski19:04:27

That's great, thank you for adding this! 😃

pithyless05:04:18

Have the RAD docs moved? Getting a 404 at http://book.fulcrologic.com/RAD.html

pithyless11:04:08

I submitted an experience report of working with RAD reports. Anyone who has worked with RAD reports, maybe would like to add/expand on it? https://github.com/fulcrologic/fulcro-rad/issues/28

👀 4
tony.kay15:04:58

I’ve responded…would love help with that..take a look at my reply and see if you have questions.

tony.kay14:04:45

@pithyless I don’t have time to update the book right now, and it is far enough out of date that I’ve unpublished it for now. The demo is the formal doc for now, and I’ve added doc strings to many keywords by turning them into simple vars, which makes it much easier to follow I think.

👍 4
❤️ 4
Jakub Holý (HolyJak)19:04:29

@tony.kay FYI On latest fulcro-rad-demo master (5a416c8) in both clj -A:dev:sql and datomic, (development/go) works but reload fails with > :error-while-loading com.fulcrologic.rad.control > :cause "Could not locate com/fulcrologic/rad/control__init.class, com/fulcrologic/rad/control.clj or com/fulcrologic/rad/control.cljc on classpath."

currentoor20:04:41

in case anyone missed it, this video shows the new hooks technique, makes it possible to easily have transient components but still retain the benefits of idents and app-state integration without figuring out a way to integrate them into the query tree really cool stuff @tony.kay! https://clojurians.slack.com/archives/C68M60S4F/p1586846034242400

aw_yeah 4
fulcro 8
🎉 8
pvillegas1220:04:46

Is there tests in some fulcro repo of testing mutations directly instead of the mutation helpers?

currentoor20:04:43

AFAIK we only test the helpers

currentoor20:04:54

too much I/O involved with testing the full mutations

currentoor20:04:16

in know in our projects that use fulcro we never test the mutations, only the helpers

pvillegas1223:04:55

I’m trying to create a component instance from a (defsc A…) declaration @U09FEH8GN is that possible?

pvillegas1223:04:34

Testing the helpers is a fine solution, however, it has its overhead with creating the mutation that passes through props to the helpers.

currentoor23:04:25

i’m not sure, i’ve never tried to do that

currentoor23:04:37

but you can use this to create props

(defn component-props [{::uism/keys [state-map]} class ident]
  (fdn/db->tree (comp/get-query class) ident state-map))

dvingo21:04:01

Hello. I'm trying to get server-side rendering working on node.js I have a http server successfully running, compiled with shadow-cljs with a repl open. I can use react-dom/server renderToString to get strings of components in com.fulcrologic.fulcro.components:

(react-server/renderToString (dom/div nil "Hi"))
; => "<div data-reactroot=\"\">Hi</div>"
But if I try to render a component, I get the empty string:
(defsc Hi [this props]
  (dom/div nil "Hi"))

(def ui-hi (comp/factory Hi))

(react-server/renderToString (ui-hi))
; => ""
Anyone have any idea why this wouldn't work?

dvingo21:04:08

The answer was in the terminal...

ERROR [com.fulcrologic.fulcro.components:682] - A Fulcro component was rendered outside of a parent context. This probably means you are using a library that has you pass rendering code to it as a lambda. Use `with-parent-context` to fix this.
FATAL [com.fulcrologic.fulcro.components:354] - Cannot find app on component!

dvingo22:04:29

Got something working:

(defsc Person [this {:person/keys [name age]}]
    {:initial-state (fn [_] {:person/name "hi" :person/age 100})}
    (dom/div
      (dom/p "Name: " name)
      (dom/p "Age: " age)))
  (def ui-person (comp/factory Person))
  (def app (app/fulcro-app))
  (app/set-root! app Person {:initialize-state? true})
  (binding [com.fulcrologic.fulcro.components/*app* app]
    (react-server/renderToString (ui-person (app/current-state app))))

dvingo22:04:47

=> "<div data-reactroot=\"\"><p>Name: <!-- -->hi</p><p>Age: <!-- -->100</p></div>"

tony.kay23:04:22

ah, that actually should not require you to do that for a pure string render…I’m probably throwing or something where I should just issue a warning

tony.kay23:04:16

but, it won’t really hurt to see the dynamic vars

tony.kay23:04:22

probably is best