Fork me on GitHub
#shadow-cljs
<
2020-06-15
>
mauricio.szabo00:06:51

By the way: nice job on node target! The console is being redirected to the REPL! Great job @thheller!

thheller09:06:14

@mauricio.szabo which version? I added the reconnect logic in 2.10.7.

mauricio.szabo13:06:25

@thheller Wow, I missed by 0.0.1 😄. It was 2.10.6 (just saw that 2.10.7 is indeed reconnecting). Thanks 😄

frankitox17:06:07

Hi, had anyone struggled with an error like the following while working with the react-native target in Android? > WebSocket connect failed:Expected HTTP 101 response but was '200 OK' I don't have a clue about how to debug such a thing. I'm trying different things like updating shadow to the latest version, destroying/creating a new ADV. I don't get any significant log errors from react-native log-android.

jimberlage17:06:18

What step is this at? I think this is a metro bundler issue - it initiates the websocket connection.

jimberlage17:06:20

Could also be a REPL, since that would also initiate the WS connection. The first step when hitting something like is for the server sending websocket messages to give a 101 Switching Protocols message, so whatever process accepts that connection is where to look. I don't think checking on-device logs will get you what you want

frankitox17:06:32

Huh. It happens once the application starts, after loading it with react-native run-android. Well, the error message also says It was trying to connect to: . I checked with --verbose when running shadow and I see the line Using IP: 192.168.0.62.

jimberlage17:06:56

Is there another process on your machine running on 9630? I'd check to see what process has that port, just to double-check that it looks like something related to react native and not another microservice or some other piece of software

jimberlage17:06:30

A webserver running on that port might return 200 OK for the initial HTTP request used to start a websocket connection

frankitox17:06:56

The shadow-cljs web server it's running on that port

frankitox17:06:26

Although I don't know if the device should do the websocket connection with shadow or the Metro thing

jimberlage17:06:23

Probably both - flipper opens a websocket connection to metro to make its displays work, and shadow would open a websocket connection to run the REPL

jimberlage17:06:53

I guess that points to a shadow issue - what version are you using?

jimberlage17:06:45

> flipper opens a websocket connection to metro React native really has a way of making you write some bizzare things. Flipper is react-native-specific devtools software, developed and maintained by facebook

jimberlage17:06:29

And metro is a process that watches for changes to JS files in your project, bundles them into one big JS file and transforms the AST to properly reference images and other react native things, and swaps out the JS file used by the react native project on your simulator.

jimberlage18:06:22

I'd try a curl/postman request to GET http://localhost:9630, so that you can see what it responds with

frankitox18:06:11

Thank you for all the info, it's very helpful! I'm using latest shadow-cljs (2.10.8). From what you say it looks more likely a problem with shadow. Doing curl -i returns that 200 OK response, which makes sense because that's were the web UI of shadow is.

thheller18:06:47

@franquito no clue why you'd be getting a 200. maybe a proxy of some kind in the middle?

thheller18:06:39

does the UI work at http://192.168.0.62:9630? from your machine and/or the android browser? it also connects to the same websocket location as react-native should? so if that works properly we can rule out shadow-cljs.

frankitox18:06:37

The UI works from the machine and the device too. > it also connects to the same websocket location as react-native should? How can I check that?

thheller18:06:53

browser devtools checking if the WS is connected?

thheller18:06:02

or just the console should log something if it failed

frankitox18:06:18

Oh, yes. The console shows that initial websocket error connection and then logs WebSocket disconnected!

frankitox18:06:51

I just disabled debugging and got a different error Error: addEventListener and attachEvent are unavailable.

thheller18:06:07

please stay with the browser for now

thheller18:06:18

does the UI work? is it fully functional?

frankitox18:06:23

The shadow-cljs UI in http://192.168.0.62:9630/ is working properly. You can even do a force compile.

thheller18:06:36

good so the websocket isn't the issue its your device connecting

thheller18:06:59

do you have more context for the addEventListener error?

thheller18:06:12

never seen that before

thheller18:06:35

don't really know what flipper is either though

frankitox18:06:18

Yes, sure, these are logs from react-native log-android

frankitox18:06:29

[15:32:23] D | ReactNative ▶︎ ReactInstanceManager.onJSBundleLoadedFromServer()

[15:32:23] D | ReactNative ▶︎ ReactInstanceManager.recreateReactContextInBackground()
                           │ ReactInstanceManager.runCreateReactContextOnNewThread()
                           └ ReactInstanceManager.tearDownReactContext()

[15:32:23] D | ReactNative ▶︎ CatalystInstanceImpl.destroy() start
                           └ CatalystInstanceImpl.destroyV1() start

[15:32:23] I | ReactNative ▶︎ [GESTURE HANDLER] Tearing down gesture handler registered for root view com.facebook.react.ReactRootView{379a637 V.E...... ......ID 0,0-1440,2392}

[15:32:23] D | ReactNative ▶︎ ReactInstanceManager.createReactContext()
                           └ Initializing React Xplat Bridge.

[15:32:23] D | ReactNative ▶︎ Initializing React Xplat Bridge before initializeBridge

[15:32:23] D | ReactNative ▶︎ CatalystInstanceImpl.destroy() end

[15:32:23] D | ReactNative ▶︎ Initializing React Xplat Bridge after initializeBridge

[15:32:23] D | ReactNative ▶︎ CatalystInstanceImpl.runJSBundle()
                           │ ReactInstanceManager.setupReactContext()
                           │ CatalystInstanceImpl.initialize()
                           └ ReactInstanceManager.attachRootViewToInstance()

[15:32:24] D | ReactNative ▶︎ ReactInstanceManager.createReactContextInBackground()
                           └ ReactInstanceManager.attachRootViewToInstance()

[15:32:25] E | ReactNativeJS ▶︎ Error: addEventListener and attachEvent are unavailable.

[15:32:25] I | ReactNativeJS ▶︎ Running "NewApp" with {"rootTag":61}

[15:32:25] E | ReactNativeJS ▶︎ Invariant Violation: "NewPibe" has not been registered. This can happen if:
                             │ * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
                             └ * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.

[15:32:25] I | ReactNativeJS ▶︎ #4 ready!

thheller18:06:24

Invariant Violation: "NewPibe" has not been registered. This can happen if:
                             │ * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
                             └ * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.

thheller18:06:31

[15:32:25] I | ReactNativeJS ▶︎ #4 ready!

thheller18:06:37

its connected just fine?

frankitox18:06:27

I can recompile from the UI. Yes, it's strange to get that message about component registration. I will try with a git bisect on my repository. Thanks for all the help! 🙏

thheller18:06:23

Error: addEventListener and attachEvent are unavailable. no clue about this one but the other one above looks like you are maybe calling registerComponent with the wrong name or not at all?

frankitox18:06:27
replied to a thread:its connected just fine?

I can recompile from the UI. Yes, it's strange to get that message about component registration. I will try with a git bisect on my repository. Thanks for all the help! 🙏

frankitox19:06:28

The problem was a bug on a new version of re-frame, It was already reported https://github.com/day8/re-frame/issues/604.