Fork me on GitHub
#fulcro
<
2020-04-16
>
Jakub Holý08:04:00

Hello! After an upgrade to the latest fulcro-rad-demo master, I have started getting this error in the browser Console

react_devtools_backend.js:6 ERROR  com/fulcrologic/fulcro/algorithms/tx_processing.cljc:413 compute-desired-ast-node's return type
 -- Spec failed --------------------
...
         :children [... {:type :join,
                         :dispatch-key
                         :com.fulcrologic.fulcro.routing.dynamic-routing/current-route,
                         :key :com.fulcrologic.fulcro.routing.dynamic-routing/current-route,
                         :query
                         [:ui/parameters :ui/cache :ui/busy? :ui/page-count :ui/current-page
                          {:ui/current-rows [:bill-run/created-date]}
                          [:ui.fulcro.client.data-fetch.load-markers/by-id _]],
                         :component minbedrift.ui.kostnadsdeling.ui/LatestBillRunList,
                         :params nil} ... ... ...],
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
should satisfy

  (fn
   [%]
   (if
    (-> % :query first (= :recursion))
    %
    (if (contains? % :children) % false)))
Full error at https://gist.github.com/holyjak/149d34ec3bfb1e7841ff639964d39f20 So the problem seems to be with the LatestBillRunList component, which is a defsc-report . If I interpret it correctly, it complains that the join is missing children. But there is not anything I could do anything about?

tony.kay15:04:31

🤷 wait for me to get back to RAD? I don’t have ideas from that .

👍 4
Jakub Holý19:04:05

FYI My top-level report doesn't fail, the one deeper in the router tree does. And the UI still works, even though this error is logged (73 times). From the error it seems this is a join, which is always expected to have :children, which this one lacks. I assume the problem is with {:ui/current-rows [...]} where normally the [...] would come from a comp/get-query and thus result in a :children element, but that is not happening in this case, the query seems to be done inline. The error is logged also for a component that is not on the screen (a secondary target of the router).

Jakub Holý07:04:28

Ok, so the error is logged when I load! the data of the parent component (that contains the router that has the report as a target). The report loads just fine on its own.

Jakub Holý07:04:06

I have made an important discovery: When I make the AST manually, the :children is there. On the other hand, the :params nil is missing from it. Is that a hint? Here is the code and data (I have changed the target component to OrgList2, a copy of a report that works elsewhere):

(eql/query->ast
    (comp/get-query DetailsDisplayRouter))
(-> *1 :children (nth 2))
=>
{:type :join,
 :dispatch-key :com.fulcrologic.fulcro.routing.dynamic-routing/current-route,
 :key :com.fulcrologic.fulcro.routing.dynamic-routing/current-route,
 :query [:ui/parameters :ui/cache :ui/busy? :ui/page-count :ui/current-page {:ui/current-rows [:tem-organization/organization-number]} [:ui.fulcro.client.data-fetch.load-markers/by-id _]],
 :component minbedrift.ui.kostnadsdeling.ui/OrgList2,
 :children [{:type :prop, :dispatch-key :ui/parameters, :key :ui/parameters} {:type :prop, :dispatch-key :ui/cache, :key :ui/cache} {:type :prop, :dispatch-key :ui/busy?, :key :ui/busy?} {:type :prop, :dispatch-key :ui/page-count, :key :ui/page-count} {:type :prop, :dispatch-key :ui/current-page, :key :ui/current-page} {:type :join, :dispatch-key :ui/current-rows, :key :ui/current-rows, :query [:tem-organization/organization-number], :component minbedrift.ui.kostnadsdeling.ui/OrgList2-Row, :children [{:type :prop, :dispatch-key :tem-organization/organization-number, :key :tem-organization/organization-number}]} {:type :prop, :dispatch-key :ui.fulcro.client.data-fetch.load-markers/by-id, :key [:ui.fulcro.client.data-fetch.load-markers/by-id _]}]}

Jakub Holý08:04:01

@tony.kay I have created the issue for this https://github.com/fulcrologic/fulcro-rad/issues/32 including simple replication step. Obviously something in alpha 13 or 14 broke load! of components that include a router with a defsc-report target. It seems the dynamically generated target AST is wrong.

dvingo15:04:30

Another SSR rendering question. The book http://book.fulcrologic.com/#_initial_route says:

If you are doing SSR, then you will need to simulate calling change-route there. The function dr/ssr-initial-state (written, but untested) can be used to help you construct the proper state for a given path (which must be used for the server-side render, and also as the initial state for the client).
I don't see this function. (ssr-initial-state) - calling change-route in node.js is throwing an error. I'm about to dig into getting the state needed to get the router in working state to render the app, but would be great if there's any pointers around this.

tony.kay15:04:49

SSR chapter has (clearly) not been updated. Use the source of application.cljc. Follow the trail through mount…you want to do everything that it does, except mount the dom

dvingo15:04:41

totally understand, thanks for the tip!

tony.kay15:04:54

If you figure it out, would love a chapter update PR on the fulcro-developer-guide repo 😉

tony.kay15:04:02

initialize-state! in app ns is most of it @danvingo

tony.kay15:04:57

if you use shared, then update-shared! is also a good idea

tony.kay15:04:39

Now, all that said, I have not personally tried SSR since F3 upgrade…so you may in fact find something that is truly broken in terms of isomorphic operation…in fact, that is highly likely. SSR simply is not on my short list of personal needs.

tony.kay15:04:39

though I guess node operation is more likely to work than JVM perhaps, since it is js. The JVM side probably has some empty functions where logic is needed for iso apps.

dvingo16:04:49

for sure, I'm happy to contribute (assuming I make it to the other side 🙂 ) yea, i'd rather just use node to render, as any js libs will also work. I got rendering working without routing, so i'm hopeful!

👏 4
dvingo16:04:43

This is working for me :

(defn init-app [root-component]
  (let [app (app/fulcro-app {:render-root! react-server/renderToString})]
    (app/set-root! app root-component {:initialize-state? true})
    (swap! (::app/runtime-atom app) #(assoc % ::app/root-factory (comp/factory root-component)))
    (app/update-shared! app)
    (dr/initialize! app)
    app))

(def a (init-app root/Root))
;; Call uism/begin! for any user state machines
(dr/change-route a ["my-route"])
(::app/app-root (app/render! a))
the app-root key contains a string of html 🙂

👍 8
tony.kay17:04:35

be careful of suggesting the use of app-root, since that will tell parts of the lib that there really is something mounted. Might be OK, but might lead to other weird errors if you then do anything else at all with that app.

dvingo17:04:31

ok gotcha, I just saw that that key contained the html string, so figured I could just access it. Is there some other way to get at it? There wouldn't be any other use of the app, from here you'd just send the string to the client to render

tony.kay17:04:38

yeah, it’s fine for the limited thing you’re doing…just saying if you then tried to run some mutations and such it could trigger future renders, and you’d have to install an optimized-render! and do other things to make sure that works

dvingo18:04:07

I was trying to use this method initially:

(react-server/renderToString (ui-component data-tree))
but the data being passed to props for a nested component (a router target) was empty, so I tried using the render! approach and that worked.

dvingo19:04:00

I can revisit when i have a better understanding of routing

dvingo22:04:37

does anyone have any suggestions to get fulcro inspect back? It's just a blank page, not the usual (no app connected) message.

dvingo22:04:02

clicking the extension button displays: "Fulcro app detected! Open Chrome Devtools and look for the Fulcro Inspect tab."

dvingo22:04:44

i just tried cloning the fulcro 3 template and confirmed the extension is blank for that too - tried in brave and chromium. deleted and reinstalled, restarted the computer..

dvingo22:04:27

I see this in the chrome console: INFO [com.fulcrologic.fulcro.inspect.inspect-client:282] - Installing Fulcro 3.x Inspect {} 18:20:03.166

dvingo22:04:41

(shrug) i installed chrome and it works there

Jakub Holý08:04:01
replied to a thread:Hello! After an upgrade to the latest fulcro-rad-demo master, I have started getting this error in the browser Console react_devtools_backend.js:6 ERROR com/fulcrologic/fulcro/algorithms/tx_processing.cljc:413 compute-desired-ast-node's return type -- Spec failed -------------------- ... :children [... {:type :join, :dispatch-key :com.fulcrologic.fulcro.routing.dynamic-routing/current-route, :key :com.fulcrologic.fulcro.routing.dynamic-routing/current-route, :query [:ui/parameters :ui/cache :ui/busy? :ui/page-count :ui/current-page {:ui/current-rows [:bill-run/created-date]} [:ui.fulcro.client.data-fetch.load-markers/by-id _]], :component minbedrift.ui.kostnadsdeling.ui/LatestBillRunList, :params nil} ... ... ...], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... should satisfy (fn [%] (if (-&gt; % :query first (= :recursion)) % (if (contains? % :children) % false))) Full error at https://gist.github.com/holyjak/149d34ec3bfb1e7841ff639964d39f20 So the problem seems to be with the `LatestBillRunList` component, which is a `defsc-report` . If I interpret it correctly, it complains that the join is missing children. But there is not anything I could do anything about?

@tony.kay I have created the issue for this https://github.com/fulcrologic/fulcro-rad/issues/32 including simple replication step. Obviously something in alpha 13 or 14 broke load! of components that include a router with a defsc-report target. It seems the dynamically generated target AST is wrong.