allen
allen2y ago

Are frequent websocket errors of

Are frequent websocket errors of WebSocket closed unexpectedly with code 1001: Stream end encountered expected behavior? It seems to reconnect and reauthenticate fine, but it happens quite often and adds a lot of noise to the ReactNative DX as it throws an error toast on the screen.
7 Replies
allen
allenOP2y ago
I'm also noticing that when it occurs it causes a full app rerender, resetting by ReactNavigation state back to the initial screen. Actually the rerender doesnt happen every time the socket disconnects/reconnects, it seems to some of the times when the reconnection also tampers with the state of my auth (which I'm using Clerk for). Maybe correlary. However, the socket drops seem to be happening way more frequently than they should, and it does at the very least reset my useQuery states back to undefined and data needs to be refetched, which makes for a wonky UX. It appears to happen consistently by letting my app idle for ~1min then firing off a mutation. I have resolved the nav state by persisting it to AsyncStorage, but the disconnect continue to happen very frequently, causing query state to reset. And mutation invocations seem to be the culprit. I'm also noticing when I kill Metro I get a warning of Disconnected from Metro (1001: "Stream end encountered"). This may be unrelated, and just a similar websocket error, but thought I'd note it. I've restructured my components to make this have less of an impact on my app, but it still is happening very frequently and seems like a bug. Seems like normal behavior should be as follows, which isnt occurring now: 1) Websocket resets should be rare 2) When they occur, the ConvexProvider should not lose the store cache. FWIW, i'm also seeing this on a build on a physical device, so its not just something with the Expo local build environment.
sujayakar
sujayakar2y ago
cool, thanks for reporting @allen. @sshader is digging into a similar connectivity issue on mobile, and it looks pretty similar (specifically "It appears to happen consistently by letting my app idle for ~1min then firing off a mutation.")
allen
allenOP2y ago
Great. Thanks for the update. Let me know if I can help. @sshader are you seeing the local cache get cleared as well when this happens?
sshader
sshader2y ago
Trying to get a similar set up on my end -- my understanding is that we currently create a new websocket whenever the auth token needs refreshing (which can be quite frequent but hopefully not every minute). This is probably too often for us to be creating a new websocket. Even with frequent web socket reconnects, it's unexpected to me that this causes queries to become undefined, so I'm trying to reproduce that on my end. Ok I definitely see a bunch of closes and reconnects in expo if I switch between apps on my phone, but so far not seeing any when I just have the app open without switching away (but will try and keep the app open and see what happens).
allen
allenOP2y ago
I'll see if I can create a minimal replica if you need. Or happy to screeshare and show you what I am seeing.
Gorka Cesium
Gorka Cesium2y ago
Could it be the hot reloading on dev?
allen
allenOP2y ago
No, I did a production internal build and installed it on a device and saw the same behavior.

Did you find this page helpful?