Skip to content

fix: only treat a reachability confirmation as a recovery when the app was offline #96634

Description

@mountiny

Problem

Production traces show serial Ping+ReconnectApp storms (up to 23 ReconnectApp calls in 52 seconds in one session) where nothing about the network changed. NetworkState fires reconnectApp() from raw NetInfo null→true transitions manufactured by boot's undefined→null→true sequence slipping past guards, NetInfo.refresh() re-emitting cached state, and the SHOULD_USE_STAGING_SERVER Onyx callback rebuilding the NetInfo subscription on every write.

Solution

The recovery branch now fires only when getIsOffline() is true at the moment reachability is confirmed, or when a one-shot pendingReachabilityRecovery token was armed by debug paths (setForceOffline, setFailAllRequests, simulatePoorConnection). The staging-server callback rebuilds the NetInfo subscription only when the effective reachability URL changed, avoiding unnecessary teardown and extra Pings. Regression tests pin that bare null→true transitions never fire reconnect while real offline recovery still works.

PR

#96504

Issue OwnerCurrent Issue Owner: @mkhutornyi

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringInternalRequires API changes or must be handled by Expensify staffPerformanceReviewingHas a PR in reviewSkip PaymentSkips all the payment process steps for an issue. Use it for fixed-price projects.WeeklyKSv2

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions