Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive queries cause errors in comp/set-query* #320

Closed
roterski opened this issue Aug 20, 2019 · 4 comments
Closed

Recursive queries cause errors in comp/set-query* #320

roterski opened this issue Aug 20, 2019 · 4 comments
Assignees
Labels

Comments

@roterski
Copy link

Hey,

I followed the recursive queries example from the book and I ran into issues when I put it together with the dynamic router.

Reproduction

When you navigate via the dynamic router to a component that has a recursive query, it throws the error:

Error: ... is not ISeqable

The component is rendered correctly when it's on the first rendered page but when you navigate to another page, and then back, it throws the error preventing the navigation.

See this behavior in the gif below:

2019-08-20 22 56 39

If you comment out this line, turning off the recursive query, the error disappears and navigation works again, but then the recursive query is gone and only the top element is displayed.

Screenshot 2019-08-20 at 23 43 22

Stack trace from https://github.com/roterski/fulcro3-book

core.cljs:159 ERROR [com.fulcrologic.fulcro.algorithms.tx-processing:348] - Failure dispatching optimistic action for AST node {:com.fulcrologic.fulcro.algorithms.tx-processing/idx 0, :com.fulcrologic.fulcro.algorithms.tx-processing/original-ast-node {:dispatch-key com.fulcrologic.fulcro.ui-state-machines/trigger-state-machine-event, :key com.fulcrologic.fulcro.ui-state-machines/trigger-state-machine-event, :params {:com.fulcrologic.fulcro.ui-state-machines/asm-id :app.ui/Router, :com.fulcrologic.fulcro.ui-state-machines/event-id :route!, :com.fulcrologic.fulcro.ui-state-machines/event-data {:error-timeout 5000, :deferred-timeout 100, :path-segment ["home"], :router [:com.fulcrologic.fulcro.routing.dynamic-routing/id :app.ui/Router], :target [:component/id :main]}}, :type :call}, :com.fulcrologic.fulcro.algorithms.tx-processing/started? #{}, :com.fulcrologic.fulcro.algorithms.tx-processing/complete? #{}, :com.fulcrologic.fulcro.algorithms.tx-processing/results {}, :com.fulcrologic.fulcro.algorithms.tx-processing/dispatch {:action #object[com$fulcrologic$fulcro$ui_state_machines$action], :result-action #object[Function]}} of transaction node {:com.fulcrologic.fulcro.algorithms.tx-processing/id #uuid "e4c7086c-d837-4e12-8798-e42d41cef6b8", :com.fulcrologic.fulcro.algorithms.tx-processing/created #inst "2019-08-20T21:17:51.548-00:00", :com.fulcrologic.fulcro.algorithms.tx-processing/options {:optimistic? true}, :com.fulcrologic.fulcro.algorithms.tx-processing/tx [(com.fulcrologic.fulcro.ui-state-machines/trigger-state-machine-event {:com.fulcrologic.fulcro.ui-state-machines/asm-id :app.ui/Router, :com.fulcrologic.fulcro.ui-state-machines/event-id :route!, :com.fulcrologic.fulcro.ui-state-machines/event-data {:error-timeout 5000, :deferred-timeout 100, :path-segment ["home"], :router [:com.fulcrologic.fulcro.routing.dynamic-routing/id :app.ui/Router], :target [:component/id :main]}})], :com.fulcrologic.fulcro.algorithms.tx-processing/elements [{:com.fulcrologic.fulcro.algorithms.tx-processing/idx 0, :com.fulcrologic.fulcro.algorithms.tx-processing/original-ast-node {:dispatch-key com.fulcrologic.fulcro.ui-state-machines/trigger-state-machine-event, :key com.fulcrologic.fulcro.ui-state-machines/trigger-state-machine-event, :params {:com.fulcrologic.fulcro.ui-state-machines/asm-id :app.ui/Router, :com.fulcrologic.fulcro.ui-state-machines/event-id :route!, :com.fulcrologic.fulcro.ui-state-machines/event-data {:error-timeout 5000, :deferred-timeout 100, :path-segment ["home"], :router [:com.fulcrologic.fulcro.routing.dynamic-routing/id :app.ui/Router], :target [:component/id :main]}}, :type :call}, :com.fulcrologic.fulcro.algorithms.tx-processing/started? #{}, :com.fulcrologic.fulcro.algorithms.tx-processing/complete? #{}, :com.fulcrologic.fulcro.algorithms.tx-processing/results {}, :com.fulcrologic.fulcro.algorithms.tx-processing/dispatch {:action #object[com$fulcrologic$fulcro$ui_state_machines$action], :result-action #object[Function]}}]}
Error: ... is not ISeqable
(anonymous) @ core.cljs:159
(anonymous) @ timbre.cljs:502
(anonymous) @ core.cljs:6955
(anonymous) @ core.cljs:6955
cljs$core$_kv_reduce @ core.cljs:700
cljs$core$reduce_kv @ core.cljs:2562
(anonymous) @ timbre.cljs:442
(anonymous) @ tx_processing.cljc:348
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5635
(anonymous) @ core.cljs:692
(anonymous) @ core.cljs:2536
com$fulcrologic$fulcro$algorithms$tx_processing$run_actions_BANG_ @ tx_processing.cljc:334
(anonymous) @ tx_processing.cljc:576
com$fulcrologic$fulcro$algorithms$tx_processing$process_tx_node_BANG_ @ tx_processing.cljc:575
com$fulcrologic$fulcro$algorithms$tx_processing$process_queue_BANG__$__STAR_pstep @ tx_processing.cljc:630
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5635
(anonymous) @ core.cljs:692
(anonymous) @ core.cljs:2536
com$fulcrologic$fulcro$algorithms$tx_processing$process_queue_BANG_ @ tx_processing.cljc:629
com$fulcrologic$fulcro$algorithms$tx_processing$activate_submissions_BANG_ @ tx_processing.cljc:261
(anonymous) @ scheduling.cljc:29
setTimeout (async)
com$fulcrologic$fulcro$algorithms$scheduling$defer @ scheduling.cljc:10
(anonymous) @ scheduling.cljc:27
(anonymous) @ tx_processing.cljc:268
(anonymous) @ tx_processing.cljc:271
(anonymous) @ application.cljc:172
(anonymous) @ components.cljc:680
(anonymous) @ components.cljc:682
(anonymous) @ ui_state_machines.cljc:132
(anonymous) @ dynamic_routing.cljc:402
(anonymous) @ dynamic_routing.cljc:424
(anonymous) @ dynamic_routing.cljc:420
(anonymous) @ ui.cljs:113
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:271
executeDispatch @ react-dom.development.js:562
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:584
forEachAccumulated @ react-dom.development.js:663
runEventsInBatch @ react-dom.development.js:817
handleTopLevel @ react-dom.development.js:825
batchedUpdates$1 @ react-dom.development.js:20440
batchedUpdates @ react-dom.development.js:2152
dispatchEvent @ react-dom.development.js:4906
(anonymous) @ react-dom.development.js:20491
exports.unstable_runWithPriority @ scheduler.development.js:256
interactiveUpdates$1 @ react-dom.development.js:20490
dispatchInteractiveEvent @ react-dom.development.js:2171

Stacktrace from my other project forked from fulcro3-template (maybe a more readable timbre trace)

timbre_support.cljs:80 ERROR [com.fulcrologic.fulcro.algorithms.tx-processing:347] -  Error: ... is not ISeqable
    at Object.cljs$core$seq [as seq] (core.cljs:1226)
    at Function.cljs$core$IFn$_invoke$arity$3 (core.cljs:2464)
    at Function.cljs$core$IFn$_invoke$arity$3 (core.cljs:2551)
    at Object.com$fulcrologic$fulcro$components$normalize_query_elements [as normalize_query_elements] (components.cljc:679)
    at com$fulcrologic$fulcro$components$normalize_query (components.cljc:711)
    at com$fulcrologic$fulcro$components$normalize_query_elements_$_normalize_query_elements_reducer (components.cljc:694)
    at core.cljs:5631
    at core.cljs:5631
    at Object.cljs$core$IReduce$_reduce$arity$3 (core.cljs:5635)
    at Function.cljs$core$IFn$_invoke$arity$3 (core.cljs:692) Failure dispatching optimistic action for AST node {:com.fulcrologic.fulcro.algorithms.tx-processing/idx 0, :com.fulcrologic.fulcro.algorithms.tx-processing/original-ast-node {:dispatch-key com.fulcrologic.fulcro.ui-state-machines/trigger-state-machine-event, :key com.fulcrologic.fulcro.ui-state-machines/trigger-state-machine-event, :params {…}, :type :call}, :com.fulcrologic.fulcro.algorithms.tx-processing/started? #{}, :com.fulcrologic.fulcro.algorithms.tx-processing/complete? #{}, :com.fulcrologic.fulcro.algorithms.tx-processing/results {}, …}0[:com.fulcrologic.fulcro.algorithms.tx-processing/idx 0]1[:com.fulcrologic.fulcro.algorithms.tx-processing/original-ast-node {:dispatch-key com.fulcrologic.fulcro.ui-state-machines/trigger-state-machine-event, :key com.fulcrologic.fulcro.ui-state-machines/trigger-state-machine-event, :params {:com.fulcrologic.fulcro.ui-state-machines/asm-id :app.ui.root/TopRouter, :com.fulcrologic.fulcro.ui-state-machines/event-id :ready!, :com.fulcrologic.fulcro.ui-state-machines/event-data {}}, :type :call}]2[:com.fulcrologic.fulcro.algorithms.tx-processing/started? #{}]3[:com.fulcrologic.fulcro.algorithms.tx-processing/complete? #{}]4[:com.fulcrologic.fulcro.algorithms.tx-processing/results {}]5[:com.fulcrologic.fulcro.algorithms.tx-processing/dispatch {:action fncom$fulcrologic$fulcro$ui-state-machines$action[p], :result-action λ[env]}] of transaction node {:com.fulcrologic.fulcro.algorithms.tx-processing/id #uuid "8964bdb4-a3b0-4229-b3b0-43ef879c6670", :com.fulcrologic.fulcro.algorithms.tx-processing/created #inst "2019-08-20T21:15:37.936-00:00", :com.fulcrologic.fulcro.algorithms.tx-processing/options {:optimistic? true}, :com.fulcrologic.fulcro.algorithms.tx-processing/tx [(…)], :com.fulcrologic.fulcro.algorithms.tx-processing/elements [{…}]}0[:com.fulcrologic.fulcro.algorithms.tx-processing/id #uuid "8964bdb4-a3b0-4229-b3b0-43ef879c6670"]1[:com.fulcrologic.fulcro.algorithms.tx-processing/created #inst "2019-08-20T21:15:37.936-00:00"]2[:com.fulcrologic.fulcro.algorithms.tx-processing/options {:optimistic? true}]3[:com.fulcrologic.fulcro.algorithms.tx-processing/tx [(com.fulcrologic.fulcro.ui-state-machines/trigger-state-machine-event {…})]]4[:com.fulcrologic.fulcro.algorithms.tx-processing/elements [{:com.fulcrologic.fulcro.algorithms.tx-processing/idx 0, :com.fulcrologic.fulcro.algorithms.tx-processing/original-ast-node {…}, :com.fulcrologic.fulcro.algorithms.tx-processing/started? #{}, :com.fulcrologic.fulcro.algorithms.tx-processing/complete? #{}, :com.fulcrologic.fulcro.algorithms.tx-processing/results {}, …}]]
(anonymous) @ timbre_support.cljs:80
(anonymous) @ timbre.cljs:502
(anonymous) @ core.cljs:6955
(anonymous) @ core.cljs:6955
cljs$core$_kv_reduce @ core.cljs:700
cljs$core$reduce_kv @ core.cljs:2562
(anonymous) @ timbre.cljs:442
(anonymous) @ tx_processing.cljc:347
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5635
(anonymous) @ core.cljs:692
(anonymous) @ core.cljs:2536
com$fulcrologic$fulcro$algorithms$tx_processing$run_actions_BANG_ @ tx_processing.cljc:333
(anonymous) @ tx_processing.cljc:575
com$fulcrologic$fulcro$algorithms$tx_processing$process_tx_node_BANG_ @ tx_processing.cljc:574
com$fulcrologic$fulcro$algorithms$tx_processing$process_queue_BANG__$__STAR_pstep @ tx_processing.cljc:629
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5635
(anonymous) @ core.cljs:692
(anonymous) @ core.cljs:2536
com$fulcrologic$fulcro$algorithms$tx_processing$process_queue_BANG_ @ tx_processing.cljc:628
com$fulcrologic$fulcro$algorithms$tx_processing$activate_submissions_BANG_ @ tx_processing.cljc:260
(anonymous) @ scheduling.cljc:29
setTimeout (async)
com$fulcrologic$fulcro$algorithms$scheduling$defer @ scheduling.cljc:10
(anonymous) @ scheduling.cljc:27
(anonymous) @ tx_processing.cljc:267
(anonymous) @ tx_processing.cljc:270
(anonymous) @ application.cljc:171
(anonymous) @ components.cljc:664
(anonymous) @ components.cljc:666
(anonymous) @ ui_state_machines.cljc:132
(anonymous) @ ui_state_machines.cljc:128
com$fulcrologic$fulcro$routing$dynamic_routing$target_ready_BANG_ @ dynamic_routing.cljc:102
com$fulcrologic$fulcro$routing$dynamic_routing$action @ dynamic_routing.cljc:108
(anonymous) @ tx_processing.cljc:345
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5635
(anonymous) @ core.cljs:692
(anonymous) @ core.cljs:2536
com$fulcrologic$fulcro$algorithms$tx_processing$run_actions_BANG_ @ tx_processing.cljc:333
(anonymous) @ tx_processing.cljc:575
com$fulcrologic$fulcro$algorithms$tx_processing$process_tx_node_BANG_ @ tx_processing.cljc:574
com$fulcrologic$fulcro$algorithms$tx_processing$process_queue_BANG__$__STAR_pstep @ tx_processing.cljc:629
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5635
(anonymous) @ core.cljs:692
(anonymous) @ core.cljs:2536
com$fulcrologic$fulcro$algorithms$tx_processing$process_queue_BANG_ @ tx_processing.cljc:628
com$fulcrologic$fulcro$algorithms$tx_processing$activate_submissions_BANG_ @ tx_processing.cljc:260
(anonymous) @ scheduling.cljc:29
setTimeout (async)
com$fulcrologic$fulcro$algorithms$scheduling$defer @ scheduling.cljc:10
(anonymous) @ scheduling.cljc:27
(anonymous) @ tx_processing.cljc:267
(anonymous) @ tx_processing.cljc:270
(anonymous) @ application.cljc:171
(anonymous) @ components.cljc:664
(anonymous) @ components.cljc:666
com$fulcrologic$fulcro$data_fetch$finish_load_BANG_ @ data_fetch.cljc:141
(anonymous) @ data_fetch.cljc:184
com$fulcrologic$fulcro$algorithms$tx_processing$dispatch_result_BANG_ @ tx_processing.cljc:520
(anonymous) @ tx_processing.cljc:533
(anonymous) @ core.cljs:2466
(anonymous) @ core.cljs:2466
(anonymous) @ core.cljs:8997
(anonymous) @ core.cljs:692
(anonymous) @ core.cljs:2536
com$fulcrologic$fulcro$algorithms$tx_processing$distribute_element_results_BANG_ @ tx_processing.cljc:530
(anonymous) @ tx_processing.cljc:544
(anonymous) @ core.cljs:5230
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5635
(anonymous) @ core.cljs:692
(anonymous) @ core.cljs:2536
(anonymous) @ core.cljs:5231
com$fulcrologic$fulcro$algorithms$tx_processing$distribute_results_BANG_ @ tx_processing.cljc:544
com$fulcrologic$fulcro$algorithms$tx_processing$process_tx_node_BANG_ @ tx_processing.cljc:580
com$fulcrologic$fulcro$algorithms$tx_processing$process_queue_BANG__$__STAR_pstep @ tx_processing.cljc:629
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5635
(anonymous) @ core.cljs:692
(anonymous) @ core.cljs:2536
com$fulcrologic$fulcro$algorithms$tx_processing$process_queue_BANG_ @ tx_processing.cljc:628
(anonymous) @ scheduling.cljc:29
setTimeout (async)
com$fulcrologic$fulcro$algorithms$scheduling$defer @ scheduling.cljc:10
(anonymous) @ scheduling.cljc:27
(anonymous) @ tx_processing.cljc:277
com$fulcrologic$fulcro$algorithms$tx_processing$add_send_BANG__$_progress_handler_STAR_ @ tx_processing.cljc:410
(anonymous) @ tx_processing.cljc:120
(anonymous) @ http_remote.cljs:299
com$fulcrologic$fulcro$networking$http_remote$progress_routine_STAR__$_progress_fn @ http_remote.cljs:242
(anonymous) @ http_remote.cljs:330
goog.events.EventTarget.fireListeners @ eventtarget.js:285
goog.events.EventTarget.dispatchEventInternal_ @ eventtarget.js:383
goog.events.EventTarget.dispatchEvent @ eventtarget.js:196
goog.net.XhrIo.onProgressHandler_ @ xhrio.js:904
XMLHttpRequest.send (async)
(anonymous) @ VM4123:1
goog.net.XhrIo.send @ xhrio.js:632
com$fulcrologic$fulcro$networking$http_remote$xhrio_send @ http_remote.cljs:60
com$fulcrologic$fulcro$networking$http_remote$fulcro_http_remote_$_transmit_BANG_ @ http_remote.cljs:335
com$fulcrologic$fulcro$algorithms$tx_processing$net_send_BANG_ @ tx_processing.cljc:151
(anonymous) @ tx_processing.cljc:185
(anonymous) @ core.cljs:2498
(anonymous) @ core.cljs:2498
(anonymous) @ core.cljs:2548
com$fulcrologic$fulcro$algorithms$tx_processing$process_send_queues_BANG_ @ tx_processing.cljc:173
(anonymous) @ scheduling.cljc:29
setTimeout (async)
com$fulcrologic$fulcro$algorithms$scheduling$defer @ scheduling.cljc:10
(anonymous) @ scheduling.cljc:27
(anonymous) @ tx_processing.cljc:286
com$fulcrologic$fulcro$algorithms$tx_processing$queue_sends_BANG_ @ tx_processing.cljc:498
com$fulcrologic$fulcro$algorithms$tx_processing$process_tx_node_BANG_ @ tx_processing.cljc:580
com$fulcrologic$fulcro$algorithms$tx_processing$process_queue_BANG__$__STAR_pstep @ tx_processing.cljc:629
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5631
(anonymous) @ core.cljs:5635
(anonymous) @ core.cljs:692
(anonymous) @ core.cljs:2536
com$fulcrologic$fulcro$algorithms$tx_processing$process_queue_BANG_ @ tx_processing.cljc:628
com$fulcrologic$fulcro$algorithms$tx_processing$activate_submissions_BANG_ @ tx_processing.cljc:260
(anonymous) @ scheduling.cljc:29
setTimeout (async)
com$fulcrologic$fulcro$algorithms$scheduling$defer @ scheduling.cljc:10
(anonymous) @ scheduling.cljc:27
(anonymous) @ tx_processing.cljc:267
(anonymous) @ tx_processing.cljc:270
(anonymous) @ application.cljc:171
(anonymous) @ components.cljc:664
(anonymous) @ components.cljc:666
(anonymous) @ ui_state_machines.cljc:132
(anonymous) @ dynamic_routing.cljc:402
(anonymous) @ dynamic_routing.cljc:424
(anonymous) @ dynamic_routing.cljc:420
(anonymous) @ post.cljs:25
callCallback @ react-dom.development.js:150
invokeGuardedCallbackImpl @ react-dom.development.js:200
invokeGuardedCallback @ react-dom.development.js:257
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:271
executeDispatch @ react-dom.development.js:562
executeDispatchesAndReleaseTopLevel @ react-dom.development.js:584
forEachAccumulated @ react-dom.development.js:663
runEventsInBatch @ react-dom.development.js:817
handleTopLevel @ react-dom.development.js:825
batchedUpdates$1 @ react-dom.development.js:20440
batchedUpdates @ react-dom.development.js:2152
dispatchEvent @ react-dom.development.js:4906
(anonymous) @ react-dom.development.js:20491
exports.unstable_runWithPriority @ scheduler.development.js:256
interactiveUpdates$1 @ react-dom.development.js:20490
dispatchInteractiveEvent @ react-dom.development.js:2171
Show 35 more frames

Both recursive queries and dynamic router are great features and I'd love to use them together.
Maybe I'm not using them correctly but then again, I tried to follow the book as closely as possible.

Let me know if I could help you in some way with debugging this issue.

@awkay
Copy link
Member

awkay commented Aug 20, 2019

Ah....the dynamic router scans queries for any nested routers. I must have overlooked the recursive query case, which should just be ignored.

@awkay
Copy link
Member

awkay commented Aug 21, 2019

Ah, this is not a dynamic router issue. The tx processing system isn't supporting recursive queries as written...I'll take a look at that.

@awkay awkay changed the title Recursive queries throw Error: ... is not ISeqable when navigating via dynamic router Recursive queries cause errors in transaction processing when used with remotes Aug 21, 2019
@awkay awkay self-assigned this Aug 21, 2019
@awkay awkay added the bug label Aug 21, 2019
@awkay awkay changed the title Recursive queries cause errors in transaction processing when used with remotes Recursive queries cause errors in comp/set-query* Aug 21, 2019
@awkay
Copy link
Member

awkay commented Aug 21, 2019

Fixed in beta-4

@awkay awkay closed this as completed Aug 21, 2019
@roterski
Copy link
Author

I confirm that the fix works in both of my projects. Thank you @awkay , awesome work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants