Fork me on GitHub
#cljsrn
<
2019-04-10
>
attentive02:04:52

Hey gang … I’ve recently ported a re-natal / re-frame project to shadow-cljs / re-frame, which was a good learning experience (I based the ported configuration on @thheller and @pez’s work on rn-rf-shadow)

attentive02:04:29

Feel a bit clueless, but one thing I’m having a bit of trouble with is the correct approach to connect a ClojureScript REPL to my running app from the command line. If anyone can give me the cheat sheet on this I’d appreciate it (with re-natal I’d just run Leiningen using the dev profile to achieve this)

attentive05:04:19

Thanks! Yeah, I saw that—but when I run (shadow/repl :browser) or (shadow/repl :react-native) I get a :no-worker error … whether from Cider or the command line

pez06:04:42

Have you done shadow-cljs cljs-repl app?

attentive06:04:52

Here’s what I’ve done: shadow-cljs watch app in one terminal (starts build and reports nREPL server started on <port>) yarn start in another (starts Metro) yarn ios in another (builds and runs XCode project) After that, I can connect to the hosted nREPL via M-x cider-connect without issues, but I can’t boost that to a CLJS repl using (shadow/repl) If I run shadow-cljs cljs-repl app in another terminal, I get a REPL prompt but trying to interact with the JavaScript runtime (eg via a (require '["react-native" :as RN])) fails telling me no application is connected

attentive06:04:36

Apologies for the long message. I’m wondering if there’s something about the way I’m launching the app on the iOS simulator that’s leaving out the entry point for the CLJS REPL connection?

thheller06:04:05

@attentive the commands look correct altough REPL require likely won't work like that since react-native doesn't really support loading dependencies at runtime

thheller06:04:51

I'm planning to do a cleanup pass over the code to allow at least requiring things that had been required before

4
thheller06:04:27

one issue I still need to solve is the proper detection of the host ip

thheller06:04:51

if it detects the wrong IP the native app will fail to connect to the websocket endpoint required for the REPL to work

thheller07:04:35

so if you don't see a WebSocket connected! console message on startup that is likely the problem

4
attentive07:04:47

Can I manually override that IP?

thheller07:04:40

you can set :local-ip in the build config currently I think

thheller07:04:17

it should be printing Using IP: ... on watch start

attentive07:04:23

Interesting! Yes it’s not doing that. Here’s the messages I see:

shadow-cljs - config: /Users/tom/dev/scout/shadow-cljs.edn  cli version: 2.8.24  node: v11.12.0
shadow-cljs - server version: 2.8.24 running at 
shadow-cljs - nREPL server started on port 52514
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (231 files, 18 compiled, 0 warnings, 5.67s)

attentive07:04:52

So I’ve been able to M-x cider-connect to the reported nREPL port 52514, but nothing beyond that

thheller07:04:02

oh try shadow-cljs watch app --verbose. it might not have the correct log level

attentive07:04:43

Okay got it Using IP: 192.168.1.120 … I’ll try adding this to :local-ip

attentive07:04:30

Thanks a lot for your assistance on this. I’ll push these changes into my de-Expo’d fork of rn-rf-shadow if it all starts to work nicely, and take a look at your doco

thheller07:04:28

that looks like its using the correct ip? or is that not the correct one?

attentive07:04:56

Yeah it does seem to be, so guess that was a red herring (that is my LAN IP currently)

thheller07:04:10

yeah it sometimes picks other ips if you have docker or other virtual container stuff running so that leads to issues. The yarn start output should be logging the websocket connected message when you open the app?

pez07:04:42

I just start things and connect the cljs-repl. No hassles. So, when you have run yarn ios, you have the app running in a simulator, or your physical device and still can't evaluate stuff from the shadow-cljs cljs-repl app prompt?

attentive07:04:44

This may be the issue: when I run yarn start it doesn’t actually run the app, it just runs the bundler

attentive07:04:10

When I run yarn ios the app runs in the simulator but I can’t connect beyond that

thheller07:04:14

but the bundler typically shows the console.log messages from the running app

attentive07:04:21

Not in my case!

attentive07:04:41

Perhaps that’s indicative of the problem (networking for the simulator?)

thheller07:04:41

really? I thought metro always did that?

attentive07:04:08

It’s just showing the BUNDLE / DELTA messages at the moment

thheller07:04:12

might be a expo only thing then

thheller07:04:25

maybe the react-native log command shows it?

thheller07:04:57

or whatever the command was. there was something to get the console.log messages of the compiled code

attentive07:04:07

I can get it using xcrun mojo but it doesn’t appear to show the Websocket Connected! message I would expect

attentive07:04:36

Yeah it’s react-native log-ios in this instance

thheller07:04:55

and it doesn't log anything?

attentive08:04:03

Nothing useful. I get the application messages from another command fine, but I don't see the websocket initialisation message. That may be because of other factors though so bear with me!

pez09:04:02

I get the Websocket Connected! message in the expo start output. Don't you get that, @attentive?

attentive09:04:25

I've removed expo from the project ... I've got a port of rn-rf-shadow off expo I'll have another poke at a little later tonight (I'm at GMT+0930 so just having dinner!)

4
attentive03:04:16

Just to come back to this issue … the REPL networking is now working correctly as far as I can determine (REPL connects from the command line). I think it might have been errors during initialisation that were causing issues before

attentive03:04:02

I can require local dependencies such as (require '[re-frame.core :as rf :refer [dispatch subscribe]]) etc so I feel like I’ve got what I need

attentive04:04:14

Still having a few issues connecting from CIDER. cider-connect seems to set up a CLJ REPL (which connects correctly) and then I can’t switch to the REPL window?

thheller07:04:20

see https://shadow-cljs.github.io/docs/UsersGuide.html#cider I think you need cider-connect-sibling-cljs

4
thheller11:04:35

@lepistane check if your index.android.js contains the goog.global=this; code? might be goog.global = this; with spaces or so, check both

lepistane11:04:27

@thheller there is but it looks like goog.global=this and also i created clean slate react native app made apk and same thing happens

lepistane11:04:35

so it's either react native/ re-natal bug

lepistane11:04:43

or i am fucking up the build process

thheller11:04:54

try changing the goog.global=this to goog.global=global

😱 4
lepistane11:04:44

this worked actually

lepistane11:04:47

what the hell!?

lepistane11:04:50

how did you know?

lepistane11:04:25

do you drink beer?

thheller11:04:27

something I added in shadow-cljs. didn't result in the error you saw but a bad assigned global has weird effects

thheller11:04:49

I dont 😉

lepistane11:04:30

why is this generated badly ? is there anyway i can fix it ?

lepistane11:04:34

for everyone else?

thheller11:04:19

as I said before I know absolutely nothing about re-natal. I would expect this to break for everyone. not a clue why it wouldn't.

thheller11:04:47

maybe its a namespace you are importing that actually uses that code. I don't know what exactly uses this.

lepistane12:04:18

i will try to pinpoint this

thheller12:04:22

search for StopIteration in the code. maybe that has some clue

lepistane12:04:54

i am using goog.functions/debounce

lepistane12:04:17

and i have setInterval

lepistane12:04:19

i will look at this

lepistane12:04:49

@thheller actually compilation passes but once i tried to type something into input field - it broke ahhhhh ok back to the drawing board

lepistane12:04:17

getting null is not an object (evaluating 'r.cljs$core$ifn$_invoce$aritiy$1')

lepistane16:04:03

Is it possible that no one has ever met this kind of behavior before?