Repository navigation
Fix Websocket reconnection stuck after network disruption - #59
Merged
Merged
Conversation
aonemd
commented
Dec 4, 2025
Member
- Add isListening flag to track and restart the message listening loop
- Tear down dead/stuck connections in connect() and create fresh ones
- Call listen() when connection becomes ready to restart message receiving
- Add isListening flag to track and restart the message listening loop - Tear down dead/stuck connections in connect() and create fresh ones - Call listen() when connection becomes ready to restart message receiving
40 tasks done
adhorodyski
added a commit
to callstack-internal/Expensify-App
that referenced
this pull request
Aug 14, 2026
We ship NWWebSocket 0.5.7 with two bugs, both fixed upstream, and both matching what our iOS clients do in production: - A reconnect that can never succeed - pusher/NWWebSocket#59, in 0.5.8. - Dead sockets that report themselves .ready - pusher/NWWebSocket#62, fixed in pusher/NWWebSocket#64, in 0.5.10. PusherSwift 10.1.6 already asks for NWWebSocket '~> 0.5.7', so only Podfile.lock was holding us at 0.5.7. Pinning the floor in the Podfile picks both fixes up with no other movement. 0.5.7..0.5.10 touches one file and changes no public API, so PusherSwift 10.1.6 links against it unchanged. OldDot shares this pod via PusherSwiftWithEncryption, so it gets both fixes too. Android is untouched. Where it hits us. 1d query on start=2026-08-09T00:00:00Z end=2026-08-10T00:00:00Z, deduplicated on (email, client timestamp): DISCONNECTED -> RECONNECTING 142,924 / 21,793 users = 6.56 100% iOS RECONNECTING -> DISCONNECTED 88,464 / 20,409 users = 4.34 100% iOS CONNECTING -> DISCONNECTED 75,672 / 19,881 users = 3.81 100% iOS RECONNECTING -> CONNECTED 25,708 / 11,327 users = 2.27 90.4% iOS Socket presumed dead (iOS) 48,954 / 21,811 users = 2.24 Only 18.0% of retries reach CONNECTED - 4.6 failures per success - and 60.6% of active iOS users entered the loop that day. Expect ReconnectApp to rise, not fall: a failed retry never re-subscribes, so fixing the loop converts 88,464 silent failures into successful connects. Why not bump @pusher/pusher-websocket-react-native to 1.3.5, which was the previous approach here. The wrapper's 1.3.1..1.3.3 diff contains no source files at all, only a podspec re-pin, and PusherSwift 10.1.6..10.1.10 changes no socket code either - both fixes are in NWWebSocket and nowhere else. What the bump does add is PusherSwift 10.1.9's swap of TweetNacl for PusherTweetNacl, a fork of the same C library. PusherSwiftWithEncryption was never published past 10.1.6, so OldDot stays on TweetNacl and both forks collide in the HybridApp binary. Dropped for a pin that carries the fixes and builds. Also fixes a dead branch in our own error plumbing. Native passed {data: {message}} with no `type`, while PusherConnectionManager gates its error handler on `'type' in error`, so every native Pusher error was dropped before any log call - 0 of 63,271 error lines carried a native user agent. Routing them through WEB_SOCKET_ERROR makes the reconnect cause attributable, which is what lets this change be measured rather than assumed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
adhorodyski
added a commit
to callstack-internal/Expensify-App
that referenced
this pull request
Aug 14, 2026
We ship NWWebSocket 0.5.7 with two bugs, both fixed upstream, and both matching what our iOS clients do in production: - A reconnect that can never succeed - pusher/NWWebSocket#59, in 0.5.8. - Dead sockets that report themselves .ready - pusher/NWWebSocket#62, fixed in pusher/NWWebSocket#64, in 0.5.10. PusherSwift 10.1.6 already asks for NWWebSocket '~> 0.5.7', so only Podfile.lock was holding us at 0.5.7. Pinning the floor in the Podfile picks both fixes up with no other movement. 0.5.7..0.5.10 touches one file and changes no public API, so PusherSwift 10.1.6 links against it unchanged. OldDot shares this pod via PusherSwiftWithEncryption, so it gets both fixes too. Android is untouched. Where it hits us. 1d query on start=2026-08-09T00:00:00Z end=2026-08-10T00:00:00Z, deduplicated on (email, client timestamp): DISCONNECTED -> RECONNECTING 142,924 / 21,793 users = 6.56 100% iOS RECONNECTING -> DISCONNECTED 88,464 / 20,409 users = 4.34 100% iOS CONNECTING -> DISCONNECTED 75,672 / 19,881 users = 3.81 100% iOS RECONNECTING -> CONNECTED 25,708 / 11,327 users = 2.27 90.4% iOS Socket presumed dead (iOS) 48,954 / 21,811 users = 2.24 Only 18.0% of retries reach CONNECTED - 4.6 failures per success - and 60.6% of active iOS users entered the loop that day. Expect ReconnectApp to rise, not fall: a failed retry never re-subscribes, so fixing the loop converts 88,464 silent failures into successful connects. Why not bump @pusher/pusher-websocket-react-native to 1.3.5, which was the previous approach here. The wrapper's 1.3.1..1.3.3 diff contains no source files at all, only a podspec re-pin, and PusherSwift 10.1.6..10.1.10 changes no socket code either - both fixes are in NWWebSocket and nowhere else. What the bump does add is PusherSwift 10.1.9's swap of TweetNacl for PusherTweetNacl, a fork of the same C library. PusherSwiftWithEncryption was never published past 10.1.6, so OldDot stays on TweetNacl and both forks collide in the HybridApp binary. Dropped for a pin that carries the fixes and builds. Also fixes a dead branch in our own error plumbing. Native passed {data: {message}} with no `type`, while PusherConnectionManager gates its error handler on `'type' in error`, so every native Pusher error was dropped before any log call - 0 of 63,271 error lines carried a native user agent. Routing them through WEB_SOCKET_ERROR makes the reconnect cause attributable, which is what lets this change be measured rather than assumed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.