Fork me on GitHub
#clojurescript
<
2016-11-21
>
credulous00:11:11

OK, so the cljsjs package is an externs-only thing, so I am supposed to go ahead and load it directly in the page.

credulous00:11:32

But the piiData is missing from the stripe.ext.js file.

credulous00:11:06

I’ll move to the String properties in your second link. Thanks, @darwin you saved me hours.

seantempesta02:11:49

Is there a way to dead code eliminate statements like this (when js/goog.DEBUG (log “debugging log call”)) if you have {:closure-defines {"goog.DEBUG" false} set? Because I’m seeing the compiled code turn into u(!1)&&Xn("debugging log call”) which seems kinda silly as it means false && log(”debugging log call”) so it can never be called. Shouldn’t this be eliminated?

verma03:11:52

it says that you should be using "if or cond in combination with an identical? comparison"

danielcompton03:11:21

@seantempesta check what happens if you use ^:boolean in front of js/goog.DEBUG

danielcompton03:11:31

that should give enough hints for the compiler to optimise it away

hwk05:11:23

https://github.com/binaryage/dirac <-- is this for real? How did I not know about a cljs repl integrated into the browser as a plugin? What are the security implications of this? (If I'm using two machines on an untrusted network).

kauko05:11:32

Same security implications as using javascript from the console I guess 🙂

hwk06:11:46

I may be paranoid, but this is what scares me: A (running lein + figwheel) and B (running chrome) are on an untrusted network if B can get a cljs repl [which typically is evalled on the server] in the browser -- that means other parties on the network can get a cljs repl doesn't this give them access on machineA ?

thheller08:11:56

@hwk to some extent yes

thheller08:11:37

although the cljs compiler never evals anything, so there are only a limited amount of ways this can affect you

thheller08:11:54

but it could certainly screw up your figwheel instance

thheller08:11:12

bind figwheel to localhost to be safe 😉

darwin10:11:04

@thheller dirac repl does not use bootstrapped, it sends code snippets to a (local) nREPL server for compilation, so potential attacker who would get access to the REPL prompt could do anything with your machine (via cljs macros for example)

darwin10:11:39

@hwk: intended setup is to run everything from a single machine and by default it binds all network services to localhost, but I’m not a security expert to tell you that this is safe

darwin10:11:38

@thheller "but it could certainly screw up your figwheel instance”, can you elaborate please?

darwin11:11:08

@seantempesta @danielcompton is correct, you have to do (if ^boolean js/goog.DEBUG (your-code)), I’ve encountered this problem myself here: https://github.com/binaryage/cljs-devtools/releases/tag/v0.5.3

darwin11:11:11

because of this incident I tend to avoid closure defines and simply use macros instead, macros can be trusted 🙂

darwin11:11:56

btw. here is a related patch which fixes cljs compiler in this regard, but it is not clear if it does not have any unintended consequences: http://dev.clojure.org/jira/browse/CLJS-1615

thheller11:11:29

@darwin well someone could send stuff to the figwheel REPL

thheller11:11:37

which then gets eval'd in your browser

thheller11:11:48

don't think one could do actual harm with that but still

thheller11:11:13

devtools should not be publicly accessible 😉

darwin11:11:42

I don’t follow, if someone could send stuff to the figwheel REPL => they gained full control over your machine

darwin11:11:04

so you have much bigger problem at hand, than messed up figwheel instance

thheller11:11:24

I didn't audit figwheel, so I cannot say if they gain full control

thheller11:11:30

I'd say it is unlikely

thheller11:11:56

but they certainly can mess with anyone connected to the REPL

darwin11:11:32

Figwheel uses cljs compiler to compile the code and compiler will drop to clojure for macro expansion, macros can do any JVM stuff, e.g access filesystem

thheller11:11:56

yes but you can't create macros via figwheel repl

thheller11:11:29

so if you don't have a "bad" macro there is no way to exploit it

darwin11:11:09

ok, I take that point

thheller11:11:35

as long as there is no eval involved you are pretty safe

thheller11:11:49

and there usually isn't

colin.yates12:11:43

Hi all (cross post from the reagent group: https://groups.google.com/d/msg/reagent-project/iSxt-KVou98/x9yl4T1OBQAJ) In brief, my understanding is that I should never see the “SAME!” console.log in the following code in 0.6.0:

(def active-stage-headers (ratom/reaction .....)
 
(defonce old-stage-header-ids (atom [])) ;; - a "normal" atom, not a reagent.ratom/atom
(def active-stage-header-ids
  (ratom/reaction
   (let [result (mapv (comp :id :patient) @active-stage-headers)]
     (if (= @old-stage-header-ids result)
       (js/console.log "recalculating stage-header-ids SAME!")
       (js/console.log "recalculating stage-header-ids DIFFERENT!"))
     (reset! old-stage-header-ids result)
     result)))
But I am seeing the “SAME!” log message in an endless loop. Have I misunderstood?

gfredericks12:11:39

@mfikes just had my first self-hosted-test.check failure; I was about to push to master and then decided I should run those tests :)

mfikes13:11:45

@gfredericks I’ll take a look.

mfikes13:11:50

Or, is it something that only occurs for a change you have locally?

gfredericks13:11:45

@mfikes: oh I didn't mean it was an active problem, just wanted to point out that you have successfully guarded against regressions. it was a use of a namespaced keyword that accidentally got $macros or whatever appended to it

mfikes13:11:58

@gfredericks Ahh cool. If I can help sort out a solution, let me know. 🙂 This might be relevant: https://github.com/clojure/clojurescript/commit/7e90ad51452ec5edd8ee7f2b7af9c7e7fb759c97

gfredericks13:11:51

@mfikes I just spelt the keyword out instead of using ::foo, and that worked

danielgrosse13:11:37

@darwin Is the nrepl connection to dirac in cursive a full functional cljs repl? I get errors like CompilerException java.lang.RuntimeException: Unable to resolve symbol: get in this context, compiling:

mfikes13:11:34

@gfredericks Yeah, you need to do that with versions of ClojureScript prior to the linked patch. From the ticket description: "a keyword like ::bar would turn in to :foo.core$macros/bar."

mfikes13:11:44

@gfredericks Your “spelled out” workaround should continue to work with newer versions of ClojureScript.

gfredericks13:11:10

@mfikes is it fixed in the latest release?

darwin13:11:34

@danielgrosse sorry, I don’t really know what do you mean by "nrepl connection to dirac in cursive”, if you mean “joined dirac session from Cursive REPL” as described here[1], then yes, anything you type/send into Cursive REPL, will act as if it was written into Dirac REPL directly: [1] https://github.com/binaryage/dirac/blob/master/docs/integration.md

mfikes13:11:52

@gfredericks Yes. That fix should work so long as test.check requires ClojureScript 1.9.293 or later. (I think I’ll write a blog post about this for people who are a little more interested in the details.)

gfredericks13:11:22

Oh I'll just do that then

mfikes13:11:27

@gfredericks No problem. My guess is that some of the newer test.check stuff will have an extra interest for people for Spec, and thus requiring a newer ClojureScript release isn’t a bad idea (as newer ClojureScript releases have been tracking Spec in the Clojure alphas / betas.)

gfredericks13:11:34

@mfikes I'm assuming the recency requirement only extends to people using self-hosted, which is already a fringey thing to do?

mfikes13:11:54

@gfredericks Yes. So, if you want to keep test.check more broadly usable (working with older ClojureScript) I’d just put in the spelled-out keyword. It doesn’t make a whole lot of sense to have self-hosted heavily influence a dep like that.

gfredericks13:11:44

@mfikes I'm thinking this change wouldn't preclude using older nonselfhosted cljs

gfredericks13:11:07

It would have the correct keyword either way

mfikes13:11:27

@gfredericks Right, with older non-self-hosted everything is cool either way.

gfredericks13:11:16

okay, so I'm going to assume there isn't anybody using self-hosted cljs for whom upgrading is difficult, in which case everything's fine

mfikes13:11:00

@gfredericks IIRC test.check is set up so that it can depend on older ClojureScript in general, but perhaps a newer version just for self-hosted purposes. So, you could even write the keyword as ::foo but require 1.9.293 only here https://github.com/clojure/test.check/blob/master/project.clj#L13

mfikes13:11:03

@gfredericks It looks like 1.9.293 is being required as the main dep, so setting it in that other spot as well would do it. (Or that bit could actually be removed.) Hah.

gfredericks14:11:50

Yeah changing that line is what I was going to do

borkdude14:11:47

Does cljs-ajax url-encode query parameters?

hwk15:11:12

@thheller , @darwin: thanks for the clarifications; I think the problem was that I confused "clojure repl" with "cljs repl" and did not realize that the "cljs repl" is much much weaker than "clojure repl", and thus not a security to the machine running "lein figwheel"

thheller15:11:13

@hwk still probably not a good idea to have it on a completely untrusted network 😛

hwk15:11:55

@thheller : yeah, repls are making me very paranoid about security

curlyfry17:11:41

@knaman I recommend #re-frame for that question! :)

johanatan18:11:23

@knaman if i'm not mistaken, reaction is in the reagent.core namespace

knaman18:11:36

@johanatan ok, y would the value not refresh in tabs-panel function is i cant figure out?

jfntn20:11:09

Is it expected that :foo/bar/baz is valid in clj but throws a reader exception in cljs?

dnolen20:11:33

@jfntn it isn’t valid in clj

jfntn20:11:23

Really? It works in the latest alpha

dnolen20:11:03

this is authoritative

dnolen20:11:34

(though ambiguous in some unfortunate cases) you’ll see that lots of cases are defined here that the reader will accept

dnolen20:11:39

and not throw on

jfntn20:11:15

right, the docs do say “once"

dnolen20:11:31

there you go

turbopape22:11:31

I’ve seen a mozilla project using clojurescript, datomish

turbopape22:11:53

I really find it cool !

niwinz22:11:44

I have a little pretty strange problems with cljs compiler: I compile the same code in 3 different environments and the result file is different (and the real problem that one of the 3 versions just crashes with an error of something is undefined). two of 3 enviroments have identical jdk version, identical lein version identical dependencies and executes identical build script, in summary, the exactly same cloned respository...) the difference between them is that one is a virtual machine in a server and other is a docker in my laptop

niwinz22:11:19

After some time researching I don't know how approach this situation, my temporal workaround is switch to :simple optimizations that works as expected... but generates 4.5 MB js file (in comparison to 1.8MB with advanced...)

hwk22:11:14

what library / function should I be using to do an AJAX Get in CLJS land? I'm using lein, figheel, devcards, reagent, re-frame, re-com

danielstockton22:11:39

cljs-http or cljs-ajax are popular choices

hwk22:11:13

@mikethompson : I just remembered. https://github.com/Day8/re-frame/blob/master/docs/EffectfulHandlers.md#90--solution actually demoted using GET. For some stupid reason I completely forgot that.

hwk23:11:04

what namespace does clojure.edn map to in cljs? It seems like my lein figwheel can find neither clojure.edn NOR cljs.edn

thheller23:11:37

@hwk cljs.reader/read-string

hwk23:11:34

@thheller: does this only appear weird to me (i.e. not cljs.edn), or is there a valid reason for cljs.reader ?

thheller23:11:48

it is just an edn reader and it is just a name so it really doesn't matter