Overview
src/services/networkMonitor.ts emits 'connectionRestored' event immediately when NetInfo reports isConnected: true. Subscribers (including requestQueue) immediately start replaying queued requests. However, the network stack may take 1-3 seconds after the isConnected event before DNS resolution and TCP connections succeed. The first replayed requests fail, are re-queued, and the retry logic starts from scratch.
Specifications
Features:
- After
isConnected becomes true, perform a lightweight connectivity probe before emitting connectionRestored
- Probe: single HEAD request to
/api/health with 5-second timeout
- If probe succeeds: emit
connectionRestored
- If probe fails: wait 2 seconds and retry probe (max 5 probes before giving up)
- Total delay: typically < 2 seconds, max 12 seconds before declaring restored
Tasks:
- Add
probeConnectivity(): Promise<boolean> in networkMonitor.ts
- Modify
NetInfo isConnected handler to call probe before event emit
- Expose
isProbingConnectivity state for UI indicators
- Add unit tests for probe success, failure, and timeout scenarios
Impacted Files:
src/services/networkMonitor.ts
Acceptance Criteria
connectionRestored event fires only after successful connectivity probe
- Queue replay does not trigger until
connectionRestored fires
- Probe timeout is 5 seconds maximum
- Unit test confirms event not emitted on probe failure
Overview
src/services/networkMonitor.tsemits'connectionRestored'event immediately whenNetInforeportsisConnected: true. Subscribers (includingrequestQueue) immediately start replaying queued requests. However, the network stack may take 1-3 seconds after theisConnectedevent before DNS resolution and TCP connections succeed. The first replayed requests fail, are re-queued, and the retry logic starts from scratch.Specifications
Features:
isConnectedbecomestrue, perform a lightweight connectivity probe before emittingconnectionRestored/api/healthwith 5-second timeoutconnectionRestoredTasks:
probeConnectivity(): Promise<boolean>innetworkMonitor.tsNetInfoisConnectedhandler to call probe before event emitisProbingConnectivitystate for UI indicatorsImpacted Files:
src/services/networkMonitor.tsAcceptance Criteria
connectionRestoredevent fires only after successful connectivity probeconnectionRestoredfires