This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-17
Channels
- # adventofcode (23)
- # announcements (2)
- # aws (11)
- # babashka (181)
- # beginners (59)
- # chestnut (2)
- # clj-kondo (9)
- # clojure (90)
- # clojure-brasil (2)
- # clojure-europe (18)
- # clojure-italy (24)
- # clojure-nl (9)
- # clojure-spec (3)
- # clojure-uk (28)
- # clojured (4)
- # clojuredesign-podcast (3)
- # clojurescript (12)
- # community-development (49)
- # core-async (49)
- # cryogen (5)
- # cursive (16)
- # data-science (1)
- # datascript (7)
- # datomic (54)
- # defnpodcast (4)
- # events (2)
- # figwheel-main (14)
- # fulcro (139)
- # graphql (1)
- # jobs-discuss (6)
- # kaocha (1)
- # luminus (2)
- # malli (3)
- # music (1)
- # off-topic (34)
- # pathom (24)
- # re-frame (13)
- # reitit (5)
- # shadow-cljs (8)
- # test-check (6)
So I'm still trying to solve my problem. I have gotten much further -- I now have the optimistic update working. However, my mutation code returns:
"Transmission was aborted because the request middleware returned nil or threw an exception"
My client and server mutations match up, and I'm pretty sure this is a client error. Here is my client mutation:
(defmutation add-person
"Mutation: add a new person with ':person/name :person/age' to the list with ':list/id"
[{name :person/name
age :person/age
list-id :list/id
tempid :tempid}]
(action [{:keys [state]}]
(swap! state assoc-in [:person/id tempid] {:person/id tempid :person/name name :person/age age})
(swap! state update-in [:list/id list-id :list/people] conj [:person/id tempid])
(js/console.log "state=" state))
(remote [env] true))
and here is my server mutation:
(pc/defmutation add-person [env {name :person/name
age :person/age
list-id :list/id
tempid :tempid}]
{::pc/sym `add-person}
(log/info "Adding person" name age "to list" list-id)
(dosync
(let [person-id (get @people-table :next-id)]
(swap! people-table assoc person-id {:person/id person-id :person/name name :person/age age})
(swap! people-table update :next-id inc)
(swap! list-table update list-id update :list/people #(conj % person-id))
{:tempids {tempid person-id}})))
I appreciate any help offered. I am getting desperate to solve this!@hadilsabbagh18 So, your code looks pretty much right
what is the return value of dosync? I don’t remember…if it isn’t serializable, then that is your problem
you’re getting a middleware exception on the server or client? you didn’t say where that exception was
Hi @tony.kay. dosync
returns the last statement. The middleware exception is on the client. The log statement on the server does not get executed.
Are you passing anything strange in as parameters? What is you call to transact!
look like?
the middleware is pretty robust, but it won’t tolerate anything that cannot be transit encoded
See also: There is a new algorithms ns called normalized-state…it has a swap!->
macro that is super nice for doing multiple steps in a mutation FYI
@tony.kay Here is my transact!
call:
(defsc AddPerson [this {:person/keys [id name age] :as props}]
{:query [:person/id :person/name :person/age :list/id :tempid]
:ident (fn [] [:person/id id])}
(let [tempid (fulcro.tempid/tempid)
new-person {:tempid tempid
:person/id tempid
:person/name "Mom"
:list/id :friends
:person/age 76}
add-person (fn []
(comp/transact! this [(api/add-person new-person)]))]
(ui-button {:onClick #(add-person)} "Add Mom!")))
I don't know if tempid
can be transit-encoded. I did not customize the app remote.
Basically I built the application described in the
added semantic UI and then added the AddPerson
component. My delete works properly and so does the optimistic update.It is in the Fulcro inspector as an entry in the local database. The console just says cannot write
.
there is a weird bug I remember transit having with respect to something…I don’t remember what…but I think that might fix it
@hadilsabbagh18 interested in knowing if that fixes it…you could also try setting the version of transit-cljs in your deps.edn if it isn’t there
also, what version of cljs? If you’re using “latest everything” it might be something in some new version of something
adding transit-clj
also did not fix the problem. I am using shadow-cljs 2.8.83
and clj 1.10.1
@hadilsabbagh18 Always start with a known good config on deps and package.json
you can update to the latest version of Fulcro, get your app working, then try bumping other deps
is there a way of adding some metadata on the server side to a query result like (with-meta results {:result-count 42})
? I was about to add a :query-count
key to all queries for this, but I just realized it can possibly be done with metadata? Or does that not cross over the wire?
metadata does not go on the wire (I think you can enable that in transit, but I don’t have it). You can always use a namespaced key…open maps are your friend.
@hadilsabbagh18 you also have cache turned off in Chrome browser while in dev mode?
@tony.kay I am going to bed. Will pick this up in the morning. Thanks for all your help!
@tony.kay I suppose the problem with adding a key to something that returns 100 results is that the key is repeated in all records and it would pollute the DB. not a big deal i guess. or I do some strange thing like return an empty record with just the meta keys, etc, but it all sounds hacky. If I wanted to turn on metadata support in transit, would that be doable in the transit wrappers on both side?
@thosmos you may also be prematurely optimizing…is it really that much space in today’s memory terms or even network speeds?
apparently transit supports it, just need to turn it on. I think it’s a cool feature to have for queries, because pagination uses total number of results before the filters are applied
I think I’ll try getting it to work with the template app and will send you a PR if it seems worthwhile (and if I actually get it working)
So I made a successful test of passing metadata from server to client DB. It’s a one-liner: (wrap-transit-response {:opts {:transform t/write-meta}})
@tony.kay Regarding passing the req to parser env: its no trouble for me to reimplement wrap-api, and I should probably do that until my work stabilises - to your point about knowing what else I need.. thanks very much for commenting.
Hi all, I am getting this error at the moment in my Fulcro app: Uncaught TypeError: Cannot use 'in' operator to search for 'fulcro$isComponent' in true
and I am not quite sure what it causes this.
Perhaps you are not passing this
(or app
) as first argument in a call to comp/transact!
. Just a guess...
I’m not sure what’s happening, but from time to time dynamic routers stop passing props to its targets and the only way to fix it is to literally clear all the caches (shadow-cljs + build). Anyone hit this behaviour? I have browser caches off + hit force refresh every time anyway.
Ah, I guess the problem is in defsc
macro: I moved the target component from one ns to another, so might be that it somehow persisted in both of them. I recall cljs macros not updating unless one cleans the build.
@thomas you are passing a boolean where a component is expected, I think. The field fulcro$isComponent
is a hidden field on components. A function tried to access it, but it found that instead of a js object it found the value true
.
yes, but the weird thing is that it works sometimes... when the value is false
I don't get the error.
This particular kind of error message is common in the clj(s) ecosystem: TypeError cannot X on/in Y…in this case X is “use ‘in’ operator to search for ‘fulcro$isComponent’” and Y is “true”
In case somebody else hits this issue: dynamic router should be elided from parent component query or else its props will get swept from that component, so it could not initialize properly (but otherwise would look ok). Spent like a few hours on this…
hm….I should beef up the default global eql transform to include that and the form config join
Hi @tony.kay. I think there is an issue with transmitting tempids. I have instrumented the client and server with debug-handlers (which returns a function that prints its arg and passes it on). I have replaced the tempid with an integer and the network problem goes away.
@wilkerlucio can you (or anyone else) think of any reason not to elide com.fulcrologic.fulcro*
keys from EQL in network requests? I’m thinking I should make the default eql transform remove those in addition to UI kws, and I can’t think of any problems that will cause.
@hadilsabbagh18 I can take a look…I have been using UUIDs a lot lately, but I’d be surprised if tempids are broken, but I would not be surprised if your deps were screwed up and transit was generally broken for your project.
@tony.kay I can't think of a reason either, but I appreciate if it can be disabled (in case we realize some need for it in the future)
@fjolne.yngling I’m pushing 3.0.16-SNAPSHOT to clojars that has a new default eql transform that removes those keys from net queries. @wilkerlucio that transform is already configurable, so it is easy to override.

sure, I just suggest keeping the strip functions separated, so the user can pull them manually and apply the ones that makes sense
ah, there is already an elide-eql-nodes function that just takes a predicate…so easy enough to use/customize
I remember that currently the thing that strip uis element is directly implemented as default-eql-transform
, can we get that out?
to save me some time: is anyone else using Fulcro tempids on network requests with Fulcro 3?
@hadilsabbagh18 I’m running the todomvc project that lives in Fulcro as a test project. It uses tempids, and is working perfectly. The deps tree for the project is:
org.clojure/clojure 1.10.0
org.clojure/core.specs.alpha 0.2.44
org.clojure/spec.alpha 0.2.176
com.fulcrologic/guardrails 0.0.9
expound/expound 0.7.2
edn-query-language/eql 0.0.9
org.clojure/test.check 0.10.0-alpha3
com.taoensso/encore 2.115.0
com.taoensso/truss 1.5.0
org.clojure/tools.reader 1.3.2
cljsjs/react-dom 16.8.6-0
com.cognitect/transit-cljs 0.8.256
com.cognitect/transit-js 0.8.846
org.clojure/clojurescript 1.10.520
org.clojure/data.json 0.2.6
org.clojure/google-closure-library 0.0-20170809-b9c14c6b
org.clojure/google-closure-library-third-party 0.0-20170809-b9c14c6b
org.mozilla/rhino 1.7R5
com.google.javascript/closure-compiler-unshaded v20180805
com.google.jsinterop/jsinterop-annotations 1.0.0
com.google.javascript/closure-compiler-externs v20180805
com.google.guava/guava 25.1-jre
com.google.errorprone/error_prone_annotations 2.1.3
org.codehaus.mojo/animal-sniffer-annotations 1.14
com.google.j2objc/j2objc-annotations 1.1
org.checkerframework/checker-qual 2.0.0
com.google.code.findbugs/jsr305 3.0.2
args4j/args4j 2.0.26
com.google.protobuf/protobuf-java 3.0.2
com.google.code.gson/gson 2.7
cljsjs/react 16.8.6-0
com.taoensso/timbre 4.10.0
io.aviso/pretty 0.1.33
com.cognitect/transit-clj 0.8.313
com.cognitect/transit-java 0.8.337
commons-codec/commons-codec 1.10
com.fasterxml.jackson.core/jackson-core 2.8.7
org.msgpack/msgpack 0.6.12
com.googlecode.json-simple/json-simple 1.1.1
org.javassist/javassist 3.18.1-GA
javax.xml.bind/jaxb-api 2.3.0
cljsjs/react-dom-server 16.8.6-0
cljsjs/socket-io-client 2.1.1-0
org.clojure/core.async 0.4.474
org.clojure/tools.analyzer.jvm 0.7.0
org.clojure/tools.analyzer 0.6.9
org.clojure/core.memoize 0.5.9
org.clojure/core.cache 0.6.5
org.clojure/data.priority-map 0.0.7
org.ow2.asm/asm-all 4.2
Hi @tony.kay. I believe I have uncovered my problem. I followed the book but it still has Fulcro 2.8 references. In particular, fulcro.tempid is 2.8. What should I use for Fulcro 3?
book updated. The ns list at beginning did list the ns, but the code in examples used the wrong alias
Hi @tony.kay. Everything works as expected now. I appreciate your efforts in helping me, I know you are busy.
welcome…I knew the “having both on the classpath” issue would bite some ppl, which is why I’ve gone to quite a bit of trouble to help ppl avoid it by even making a fork of workspaces that is f3 only. It’s OK for them both to be there, but they are not compatible with each other, as you found
Hi All... still a bit confused here... I have a query for a value and I destructure the keys as well. I can see the value in the Fulcro Inspect tools (great tool BTW). but the value is null when I print it 😞
when I have this problem it usually means that I forgot to put the key on the query part, or Im looking into the wrong ident
I have figured it out... I had indeed a boolean where I should have done a (comp/get-query .... )
I'm playing with the react native fulcro 3 template but can't get the fulcro inspector electron app to connect to the mobile app in the simulator, how do I debug that?
I've uncommented the line in shadow file for the react target and restarted the web app server and mobile app
android won’t deal with “localhost”…to use it with inspect you have to figure out the IP address of you machine and set it via a goog define…
:dev {:closure-defines {com.fulcrologic.fulcro.inspect.inspect_ws/SERVER_HOST "x.x.x.x"}}
@UCJCPTW8J Yes, definitely with the _. I just tested it, and it works (via web…not react, but that is the issue for android and devices)
I'm using the iOS simulator because of a different issue with using my phone, it appears to just work in your video, this is what I'm seeing https://i.imgur.com/4mqHGFH.png and this is my shadow-cljs.edn