feat: debounce_timing [rn]#28
Merged
choudlet merged 9 commits intoApr 10, 2026
Merged
Conversation
Add network connectivity awareness to the React Native SDK so events queue in memory while offline and flush on reconnect. - NetworkMonitor TS wrapper + native bridge modules (iOS NWPathMonitor, Android ConnectivityManager) - CircuitBreaker.reset() clears stale backoff on reconnect - Dispatcher guards flush with isNetworkAvailable() - MetaRouterAnalyticsClient wires network monitor via DI - Add maxOfflineDiskEvents to InitOptions (for PR 2) - Comprehensive tests for all new behavior Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Online transitions are debounced by 2s to prevent circuit breaker resets, wasteful flushes, and churn during rapid network flapping. Offline transitions remain immediate. networkStatus stays 'disconnected' during the debounce window so the dispatcher's isNetworkAvailable() continues to block flush attempts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
brandon-metarouter
approved these changes
Apr 10, 2026
Collaborator
brandon-metarouter
left a comment
There was a problem hiding this comment.
Left some take it or leave it comments!
| err | ||
| ); | ||
| .catch(() => { | ||
| /* fallback: stay connected */ |
Collaborator
There was a problem hiding this comment.
Just checking if log removal is intended.
| err | ||
| ); | ||
| } catch { | ||
| // Native module not available — stay as always-connected (default behavior) |
Collaborator
There was a problem hiding this comment.
Same here, just double checking log removal.
| @@ -0,0 +1,73 @@ | |||
| import type { NetworkReachability, NetworkStatus } from './networkMonitor'; | |||
|
|
|||
| const DEBOUNCE_MS = 2_000; | |||
Collaborator
There was a problem hiding this comment.
If this is only used in DebouncedNetworkMonitor, maybe a class const instead? Something like private static readonly DEBOUNCE_MS = 2_000; ?
| expect(stopSpy).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('online transition is debounced — rapid flapping produces single flush', async () => { |
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.
Summary
Adds 2-second debouncing to network reachability online transitions. Offline transitions remain immediate. This prevents circuit breaker resets, wasteful flushes, and churn during rapid network flapping (e.g., tunnel, elevator, weak cell signal).
Ticket: SC-37711
Changes
Test plan
reset()cancels pending debounce timer