Fork me on GitHub
#shadow-cljs
<
2024-02-20
>
Patrick Brown14:02:35

I’m having some issues connecting my shadow-repl to expo react native. In my terminal window launching expo (dev build or go app, IOS or Android) I get ERROR shadow-cljs watch for build :native not running! The result is that expo’s garbage hot reload works and the good one shadow gives me doesn’t. I’ve attached screenshots of the stack available on simulator. The error I don’t get is the shadow-cljs - remote-error {"isTrusted": false …} . I get that error and others like Stale Output! as expected when I C-c my shadow watch terminal. It appears like on some real level the shadow connection is being observed. I’m available to help anyone who is interested in helping me. CHEERS!

thheller14:02:30

I suspect that you have shadow-cljs running twice in the project

thheller14:02:43

they basically interfere with each other and overwrite each others files

Patrick Brown14:02:55

I think you’re right.

thheller14:02:59

make sure to kill them all and start a clean one

Patrick Brown14:02:21

No dice. I deleted my .shadow-cljs, and my build files, launched my native build and I’m getting the same error. Did I miss the point?

thheller14:02:43

yes. deleting the files is exactly what will get you into this mess

thheller14:02:52

the .shadow-cljs files keep references to the running process

thheller14:02:06

so by deleting them you remove any trace of something that may still be running

thheller14:02:11

basically never ever do that, there is never a good reason to

thheller14:02:33

what you need to do is kill the running java processes

Patrick Brown14:02:49

Oh, we are definitely talking about 2 different things

thheller14:02:53

or if you can still access it open a REPL and type (System/exit 0)

thheller14:02:34

but that won't work if there is a zombie process which you can't connect to anymore because you deleted the files

thheller14:02:40

when in doubt just reboot 😛

thheller14:02:05

just make sure there is no running java process in that project directory

Patrick Brown14:02:00

so I killed all java processes, started my shadow watch, ran my expo development build and I’m getting the no connection error.

thheller14:02:36

ok, now that we are in a clean state we can investigate further 😛

thheller14:02:43

what is expo trying to connect to?

Patrick Brown14:02:53

This was expected behavior for me. My wires were crossed, because I often build my browser and native builds at the same time through a npm run script.

Patrick Brown14:02:21

I’ve done both the go app and a dev build, ios and android simulator. ATM it’s a dev build on ios

thheller14:02:32

you can do that via shadow-cljs watch native node, it should not be 2 separate shadow-cljs commands in case you are doing that

thheller14:02:09

> what is expo trying to connect to?

thheller14:02:28

does it give you any indication what host it tried to connect to? an ip or something?

thheller14:02:57

> I’m getting the no connection error.

thheller14:02:03

so not the "build not running" error?

Patrick Brown14:02:40

It does not. I’ve given you all the errors I’m getting. It’s surprisingly thin, just a singular log line and the stack on the simulator

Patrick Brown14:02:10

I get “sahdow-cljs watch for build :native not running!”

thheller14:02:12

just to confirm

thheller14:02:20

ok please take a second

thheller14:02:32

and be extra clear about what errors you are getting

thheller14:02:38

> “sahdow-cljs watch for build :native not running!”

thheller14:02:43

means that the connection worked just fine

thheller14:02:53

since otherwise it wouldn't know that the build is not running

thheller14:02:00

> shadow-cljs - remote-error {"isTrusted": false …}

thheller14:02:07

this is the "no connection error"

thheller14:02:28

they are two very different things with very different causes, so please be clear

Patrick Brown14:02:30

I get that error when I expect to, i.e. after I C-c my build.

thheller14:02:55

sorry I have an extremely hard time following you

thheller14:02:19

lets start from the beginning

Patrick Brown14:02:22

I’m sorry. I’m not the most graceful online. I’m not trying to be bad at this.

thheller14:02:35

you start npx shadow-cljs watch native?

thheller14:02:44

what does that log give you

thheller15:02:01

please just paste the entire log

thheller15:02:21

I want to get away from me guessing what is happening 😛

Patrick Brown15:02:53

› Installing on iPhone SE (3rd generation) › Opening on iPhone SE (3rd generation) (net.drilling) › Opening on iPhone SE (3rd generation) › Opening the iOS simulator, this might take a moment. › Logs for your project will appear below. Press Ctrl+C to exit. iOS Bundled 4255ms (index.js) LOG debug LOG start LOG shadow-cljs #3 ready! ERROR shadow-cljs watch for build :native not running!

thheller15:02:04

that is not the log I asked for

thheller15:02:19

I literally want you to run npx shadow-cljs watch native and give me that log

Patrick Brown15:02:23

➜ shadow-cljs watch app/native shadow-cljs - config: /Users/pat/fjck/shadow-cljs.edn shadow-cljs - socket connect failed, server process dead? shadow-cljs - starting via “clojure” shadow-cljs - HTTP server available at http://localhost:5308 shadow-cljs - HTTP server available at http://localhost:5309 shadow-cljs - server version: 2.27.4 running at http://localhost:9630 shadow-cljs - nREPL server started on port 5310 shadow-cljs - watching build :app/native [:app/native] Configuring build. [:app/native] Compiling ... SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”. SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. [:app/native] Build completed. (182 files, 0 compiled, 0 warnings, 3.66s)

thheller15:02:23

I don't care about expo yet

Patrick Brown15:02:33

Am I supposed to report back something specific?

thheller15:02:42

you should see your builds, with native running (aka green dot)

thheller15:02:55

ok, just checking

thheller15:02:06

so now if you start expo

thheller15:02:33

start and leave it running, no ctrl+c anything please. both processes.

Patrick Brown15:02:13

It’s loaded with the shadow error in question in a popup on the bottom.

thheller15:02:23

which shadow error

thheller15:02:28

build not running?

thheller15:02:06

how many items are listed?

thheller15:02:18

should have #1 JVM Clojure, and then more?

Patrick Brown15:02:38

2, I’ve got “#1 JVM Clojure” and “#5 - build: native”

thheller15:02:53

so it connected just fine

thheller15:02:35

and if you click back to builds the native build is definitely still running?

thheller15:02:13

about you had shadow-cljs watch app/native ?

thheller15:02:27

what is the actual build id? namespaced keywords are not allowed there

thheller15:02:11

so there is a :builds {:app/native {:target ...}} config in shadow-cljs.edn?

thheller15:02:30

well .. that is obviously not :native, so no wonder it cannot find it

thheller15:02:46

make that :app-native or just :native and you should be fine

thheller15:02:56

build ids should not be namespaced keywords

Patrick Brown15:02:23

Oooof, It didn’t cause issues for tests or the browser version.

Patrick Brown15:02:34

man, I feel I should know that.

thheller15:02:18

I don't have an immediate guess why its a problem in expo, but I mean now that we found it its pretty obvious 😛

Patrick Brown15:02:19

Well, I really enjoy your tool. It doesn’t give me issues like this. Most everyday it just helps me work. So thanks for this and shadow.

Patrick Brown15:02:05

CONFIRMED: namespaced build id caused hot reload to break in expo. Thanks @U05224H0W

thheller15:02:07

should at the very least give the correct error 😛