Fork me on GitHub
#fulcro
<
2018-10-23
>
pvillegas1200:10:04

I’m getting this weird behavior using fulcro spec in the browser. I have a test that is showing in the spec UI (with no tags like :focused) and when I change the test the defines the mutations (not the test file), my spec disappears from the fulcro UI. I start changing the test file and the spec comes back green.

tony.kay01:10:03

@pvillegas12 make sure you’re on the latest version. I tried to fix that, but am not sure why it happens

tony.kay01:10:03

I’ve seen it as well, but I don’t really have a clue…is the console saying anything?

tony.kay01:10:12

like a React exception caused it to not render?

pvillegas1201:10:12

It warns about the Root render taking too long

pvillegas1201:10:32

@tony.kay still getting the same behavior after updating :thinking_face:

pvillegas1201:10:53

this happens when I save the file that defines the function under test

tony.kay03:10:08

yeah, that warning is nothing.

tony.kay03:10:47

I had never seen it before I started using shadow-cljs…you using that as well?

tony.kay03:10:16

could be some order-dependent thing in the code that shadow does diff than figwheel

pvillegas1210:10:34

yes, using shadowcljs

thheller10:10:05

FWIW I just checked whats happening and identified the problem. its a fun one 😛

thheller10:10:25

since shadow-cljs dynamically adds the namespaces based on a regexp

thheller10:10:41

the client-test-main ns doesn't have an explicit dependency on those

thheller10:10:53

and thus parallel compile does not wait for them to complete compilation

thheller10:10:09

so when the macro that sets ups the tests does its thing

thheller10:10:23

the namespaces are still "in progress" so the tests are not found

thheller10:10:54

quick fix is adding the namespaces manually like you would in figwheel

thheller10:10:28

I'll see if I can adjust the :browser-test target. I did not account for side-effecting macros in the :runner-ns

pvillegas1212:10:20

@U05224H0W including the namespace of the spec in client-test-main did the trick thanks! 😄 Do let us know when there is a better one 😉

thheller15:10:15

should be fixed in 2.6.15

👍 4
parrot 8
currentoor20:10:23

@U05224H0W I noticed some weirdness with the tests, it appears hot code reloading is not working

currentoor20:10:23

for example if i add a top level print statement, i see some activity in the JS log about reloading but none of my print statement

currentoor20:10:47

similarly, updating tests seems to have no affect either

currentoor20:10:23

and there is this error in the JS log

goog.net.xhrio.js:627 OPTIONS  405 (Method Not Allowed)

Failed to load : Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' is therefore not allowed access.

tony.kay21:10:37

@U09FEH8GN out of curiosity, does using “http://test.lvh.me” instead of localhost change anything?

currentoor21:10:23

nope, same error and behavior

currentoor21:10:38

the error has instead of localhost

tony.kay21:10:55

yeha, on reflection that shouldn’t have helped 😜

tony.kay21:10:22

so, are the changed files going over the network in the network tab?

currentoor21:10:32

just that request the error logs is failing no other network activity

thheller21:10:05

@U09FEH8GN is that new or was it always that way? I do set the CORS headers so it should be working?

tony.kay21:10:56

I’ll try it and see

tony.kay21:10:29

confirmed. 2.6.15 is not getting updated source because of a CORS error

tony.kay21:10:54

Request URL: 
Request Method: OPTIONS
Status Code: 405 Method Not Allowed
Remote Address: [::1]:9630
Referrer Policy: no-referrer-when-downgrade
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Connection: keep-alive
Content-Length: 0
Date: Tue, 23 Oct 2018 21:52:24 GMT
Expires: 0
Pragma: no-cache
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Access-Control-Request-Headers: content-type
Access-Control-Request-Method: POST
Cache-Control: no-cache
Connection: keep-alive
DNT: 1
Host: localhost:9630
Origin: 
Pragma: no-cache
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36

tony.kay21:10:27

ipv4 vs v6???

tony.kay21:10:56

@U05224H0W definitely broken in 2.6.15, but works in 2.6.13

tony.kay21:10:11

I’m working on the same source as @U09FEH8GN

thheller21:10:42

never change a running system ... looking into it

thheller22:10:41

fixed in 2.6.16

thheller22:10:01

definitely need to find a way to test watch and live-reload in CI somehow

thheller22:10:17

that should have been caught way earlier

tony.kay23:10:37

@U05224H0W golden…works perfectly, and maybe even seems faster than having to pre-require everything

thheller08:10:40

the faster part is from the other changes I did recently. test namespaces generally fit very well into parallel compile and that got way faster the more parallel it gets

tony.kay15:10:51

yeah, I have not measured, but it was noticeable

kirill.salykin09:10:41

hi is any built in http request support in fulcro? what is need is just read …/VERSION file and output it somewhere

kirill.salykin09:10:05

or should I use http from Google Closure?

claudiu09:10:20

@kirill.salykin There is the network and you have http://book.fulcrologic.com/#_request_middleware the request/response MW think you could just add a new remote with MW that does that request for you, but seems like a bit of work if that's you're only use-case. The network part seem like the only abstraction for http and it uses xhrio directly https://github.com/fulcrologic/fulcro/blob/develop/src/main/fulcro/client/network.cljc#L306

kirill.salykin09:10:00

it is indeed to much overhead with MW

tony.kay15:10:47

closure if you’re just trying to do some side-band thing one-off

kirill.salykin15:10:01

Yep, did it this way. Thanks )

devo15:10:17

As anyone worked with rdflib.js in fulcro, or any sort of parallel client-side store similar to the rdf graph in that library? Would you want to treat that as a remote?

devo15:10:10

I think that the correct way to do this long-term would be to use something like a SPARQL client / apache jena server-side and go through the normal fulcro flow, but wanted to know if anyone had ideas for a client-side only solution since that would be faster / simpler for a lunch and learn.

wilkerlucio16:10:32

@devo pathom has some of these properties, it can run on JVM or Browser and supports parallel processing of the queries, its not RDF, I'm taking a look at the library and seems that pathom connect feature shares some ideas about data linkage, but the implementation is something different https://github.com/wilkerlucio/pathom

wilkerlucio16:10:30

the parallel parser is not documented yet (coming soon) but the code is been used in prod for some time, if you follow the pathom docs the configuration is similar to async-parser, please let me know if you want to try it out

wilkerlucio16:10:41

I never got to do some proper research on RDF, could you please tell me what you looking for on it? how it is used? is it like a thing that composes over distributed data graphs?

devo16:10:47

currently doing a lunch and learn over the SOLID protocol, which is built on RDF, so pretty new to it as well 🙂. The idea is that RDF formats like Turtle or JSON-LD store relationships in triples and are hosted arbitrarily (e.g. https://devereux.solid.community/profile/card#me). You can then use xml describing relationships to query information across those files (e.g. my friends using ). The existing library is both a web client and a store that fetches remote documents and loads them + their relationships into a client side store for later querying.

tony.kay16:10:19

@devo for a lunch and learn you could use Datascript to simulate a datomic back-end and a pathom parser as the “remote”

4
tony.kay16:10:37

all in a browser

tony.kay16:10:01

not sure what you’re trying to teach

devo16:10:27

Mostly to show off SOLID, but wanted to do it with fulcro just to get some more experience with the framework.

tony.kay16:10:32

ok, so since the concept is that you have distributed data stores that all have separate ownership and such, you could set up multiple datascript databases in the browser, and one pathom parser that can resolve to them in a unified query sense (e.g. Fulcro would be unaware that they were federated)

tony.kay16:10:02

the client-side async pathom parser can do any async kinds of processing, so you could also have it hit a bunch of different real network endpoints

tony.kay16:10:15

depends on what level of simulation your trying to do

tony.kay16:10:51

I’m not sure if any of that is relevant, now that I look at some of the introduction stuff on SOLID

wilkerlucio16:10:07

this is the solid you are talking about? https://github.com/solid/solid

tony.kay16:10:08

@devo I don’t really know of anything that is likely to serve your specific lunch-and-learn criteria…seems like using node for a server might be the best you can do, but you could host a single server that everyone could hit, perhaps?

👍 4
devo16:10:37

no worries! Was just trying to get some ideas, and definitely have a few to play around with now. Will probably pull in pathom and start playing around with resolvers / networks to see what seems best.

hmaurer16:10:19

@tony.kay slightly off-topic question but do you know how to evaluate forms in the clojurescript repl with Cursive? The normal command (eval in REPL) spits “Cannot load ClojureScript form into Clojure repl”

johnny16:10:18

@hmaurer You need to start a clojurescript repl first

hmaurer16:10:40

@johnny I’ve one running I think, with figwheel

johnny16:10:42

Which in my experience is a separate thing in cursive

hmaurer16:10:52

script/figwheel.clj from Fulcro’s lein template

johnny16:10:37

(require '[user :refer [start-figwheel]])
(start-figwheel)

johnny16:10:45

Got the same thing with this as content

hmaurer16:10:00

ooh I just realised there is a small dropdown at the top of the repl with “clj” and “cljs” as selections

hmaurer16:10:03

I switched it to “cljs”

hmaurer16:10:06

it works now

hmaurer16:10:09

:face_with_rolling_eyes:

tony.kay16:10:18

strange it didn’t auto-switch…it usually does

johnny16:10:38

Ye never seen that issue

kardan17:10:11

What are people using for cljs builds, Shadow or Figwheel (& the rest)?

tony.kay17:10:23

I’m using shadow-cljs on many different projects (3 commercial). A lot of my older OSS work is on figwheel (as it helps ensure I don’t break users that use figwheel), but I prefer shadow-cljs.

👍 8
tony.kay17:10:15

- better responsiveness from the maintainer - better integration with js ecosystem - better caching and cache invalidation (I almost never have to “clean” compiled stuff)

thheller17:10:04

almost? 😛

tony.kay17:10:53

I’ve had to clear .shadow-cljs on a few upgrades

tony.kay17:10:02

so, pretty rare

hmaurer17:10:06

@tony.kay do you have a sample project with shadow? The book uses the Kevin template iirc

tony.kay17:10:21

lein new fulcro app shadow-cljs

hmaurer18:10:31

Do you use a remote REPL for shadow with Cursive?

tony.kay18:10:04

you just connect to a remote nREPL from cursive, and type (shadow/nrepl-select :name-of-build)

tony.kay18:10:29

shadow prints out what port to use, or you can pre-set it (which is what I do so I don’t have to edit the run config all the time)

hmaurer18:10:16

@tony.kay ah; I was trying to start a repl with npx shadow-cljs cljs-repl watch cards; I’ll try what you suggest

tony.kay18:10:08

yeah, I just do npx shadow-cljs watch cards and use the nrepl port it prints out on startup

hmaurer18:10:12

shadow-cljs - socket REPL running on port 63355
shadow-cljs - nREPL server started on port 9000
Port 9000 gets me to a clojure repl though, not a clojurescript repl, right?

tony.kay18:10:00

nrepl-select above

tony.kay18:10:13

tony.kay [15 minutes ago] you just connect to a remote nREPL from cursive, and type (shadow/nrepl-select :name-of-build)

hmaurer18:10:20

ah right, sorry!

hmaurer18:10:40

so the nREPL running gives me a clojure rep, then that switches to a cljs repl

hmaurer19:10:18

@tony.kay one extra question… in the intro devcard file you generate:

(ns elogic.intro
  (:require [devcards.core :as rc :refer-macros [defcard]]
            [elogic.ui.components :as comp]))

(defcard SVGPlaceholder
         "# SVG Placeholder?"
         (comp/ui-placeholder {:w 200 :h 200}))
it seems like cursive picks up devcards.core as a JS dependency. If I CMD-click on devcards.core it brings me to a JS file, and consequently cursive can’t resolve the defcard macro. Have you run into this?

tony.kay19:10:15

occasionally…I think it might be a stubs/index thing

tony.kay19:10:36

look to see if it is asking you to generate stubs, or is indexing

tony.kay19:10:47

could also do IntelliJ “Invalidate caches and restart”

tony.kay19:10:03

then ask on #cursive if it keeps happening

hmaurer19:10:59

@tony.kay neither asking to generate stubs, nor indexing. I invalidated caches and restart, still having the issue. I’ll ask on #cursive, thanks

hmaurer19:10:35

I seemingly wasn’t having that issue with the figwheel setup by the way :thinking_face:

hmaurer19:10:36

ah wait no you’re right, it is asking to generate stubs

hmaurer19:10:34

Error generating stubs for module elogic
Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.

tony.kay19:10:39

oh, just delete the jvm-opts from the project file

tony.kay19:10:07

otherwise you have a syntax error that is keeping cursive from evaluating your code, which will prevent stubs from completing

tony.kay19:10:28

the jvm-opts is prob not the problem…just the cause of that warning

hmaurer19:10:54

@tony.kay ah, thanks. There doesn’t seem to be more info on why it can’t generate the stubs though 😞 and without them defcard is not recognised as a macro

hmaurer20:10:32

@tony.kay actually… after removing the UseConcMarkSweepGC from the project file the stub generation completed without error. It hasn’t solved the issue with defcard though

tony.kay17:10:50

it would be the default instead of figwheel, but I have not had time to rewrite the dev guide

hmaurer18:10:53

oh, easy-peasy! thanks

kardan18:10:19

I have to say that I’m a bit confused on how to structure things and get a clojure & a clojurescript repl. Worked on a Clojure / React project before, so never “had” to deal with ClojureScript much

kardan18:10:15

I’m bike shedding a lot on docker-compose related things at the moment …

kardan18:10:37

Thanks for the direction

pvillegas1218:10:39

With ui routing I have a top level function nav-to! similar to the one defined in the fulcro template. I’m having trouble composing this call (which ends up calling prim/transact!) and other mutations. Say I want to change the state and navigate to another URL. Is the correct way to do this is making a mutation that calls nav-to! within it? This would nest transact! calls which I read were not desired

tony.kay18:10:04

@kardan I recommend using IntelliJ community edition with Cursive…both are free to use for tinkering, and both are reasonably priced for real work. Then use the shadow-cljs version of the lein template…the README it generates should get you going.

kardan18:10:36

I actually bought Cursive to try it but so far I’m using Cider because it’s what I’m used to

kardan18:10:22

But it’s on my todo list once work gets a bit less…

tony.kay18:10:55

understandable…a lot of ppl on channel use spacemacs, and the template is intended to work well with it. Let me know 🙂

hmaurer20:10:21

@tony.kay bringing the discussion here as it might be relevant to other people trying the shadow-cljs template. Moving the devcards dependency to :dependencies in the project file (instead of under :profiles :cljs :dependencies) seems to have fixed the issue for me

hmaurer20:10:31

Ah wait, I just realised it might have been much stupider than this. Checking the cljs profile in Leiningen Projects > Profiles seems to be enough

tony.kay20:10:33

ah yes, it has to be visible on deps 🙂

tony.kay20:10:43

forgot about that bit

hmaurer20:10:44

Sorry, that should have been obvious to me. I just started using intellij :face_with_rolling_eyes:

hmaurer20:10:55

By any chance, would you know where Cursive stores the Resolve as... settings?

hmaurer20:10:09

I looked in the .idea directory but couldn’t find them

hmaurer20:10:23

(to know if it’s per-project and will get commited to git)

tony.kay20:10:10

probably ~/Library on a mac…once resolved they are global

hmaurer21:10:08

Yet another question… Has anyone done “query whitelisting” with Fulcro? i.e. list all the queries that the application might run, store those on the server and only accept queries in that set

hmaurer21:10:11

(for production)

hmaurer21:10:16

“persisted queries” is the term used in the graphql land I believe

tony.kay21:10:43

I prefer to set permissions on edges of the graph

tony.kay21:10:36

i.e. indicate, via authorization, which edges of the graph a user is allowed to traverse (and which scalars they can read)…then you can easily look at the query (reduce the keys to a set) to see if there are any “disallowed” keys in the query

tony.kay21:10:10

that doesn’t interfere with graph query flexibility, but gives you the security

tony.kay21:10:38

you also need to check the “root set” of their incoming request, of course. “Can I start here?”

tony.kay21:10:28

Namespaces on keywords gives you a nice way of resolving ambiguity that arises from context

tony.kay21:10:16

but the root set is usually required to make it work right, even with that (e.g. ensuring you don’t walk to another user through edges is easy, but the protections on :user/address might say it’s ok to read…assuring that they don’t start (and cannot traverse through edges) can prevent that.

eoliphant21:10:06

quick question. I'm getting my backend wired up with pathom (backed by datomic and some other stuff). in say datomic, I use 'discriminator' ID's :person/id, etc. The client, like say datomic uses :db/id by default. What's the best way to map/translate between the two? Presumably I can override ;db/id on the client, but that seems like it would get messy. And I guess my queries server mutations could do the mapping on the server. Just trying to figure out what makes the most sense.

tony.kay21:10:36

you’re going to have :db/id no matter what. Add a UUID column for :person/id, which is unique-identity

tony.kay21:10:16

that way you can still use tempids on :db/id (to detect optimistic results), but pathom will work well because queries can distinguish on discriminator IDs

tony.kay21:10:42

then normalize in the ui on your disc. IDs

eoliphant12:10:13

so when I return results, map :person/id -> :db/id ?

tony.kay15:10:27

no. you can query for :db/id if you need it, but :person/id is a unique field that is also identity (UUID)

tony.kay15:10:26

queries stress using the UUID…mutations send a tempid for :db/id so that you can see when remaps happen…the client can safely generate a UUID for :person/id, but the server need not rewrite it, so there would be no way for you to know (by looking at the data) if the server had succeeded in storing a new one.

hmaurer21:10:43

elogic.client/app
=> nil
(deref elogic.client/app)
=> nil
(keys (deref elogic.client/app))
=>
(:initial-state
 :mutation-merge
 :started-callback
 :remotes
 :networking
 :send-queues
 :response-channels
 :reconciler
 :read-local
 :query-interpreter
 :mounted?
 :reconciler-options
 :lifecycle
 :parser)
@tony.kay it seems like trying to get the app atom from within the cljs repl returns nil (and throws an error in the browser console).

hmaurer21:10:04

I seem to recall you saying this could occur when the payload was too big?

tony.kay21:10:45

if you want to see the app state value, don’t do it that way…first, you should use Fulcro Inspect chrome plugin…but if you want to play with app state at a REPL, use (prim/app-state (:reconciler @app-atom))…and that itself is an atom

hmaurer23:10:19

I use Fulcro inspect, I was just messing around with the REPL to see what I could access and how things were structured 🙂

tony.kay00:10:50

cool…yeah, you can get in trouble printing things…esp if they are large

tony.kay00:10:08

or self-referential in a loop (circular linked list)

tony.kay21:10:52

Depending on the REPL/build system you’re using, it is possible to overflow the message size and see weird things…I used to cause it in Figwheel, but I no longer dump large things in the REPL, and have not seen that issue in a long time personally