feat(data-connect): add intelligent reconnection to streaming transport #9893
feat(data-connect): add intelligent reconnection to streaming transport #9893stephenarosaj wants to merge 6 commits intopasta/mainfrom
Conversation
|
There was a problem hiding this comment.
Code Review
This pull request implements automatic reconnection logic with exponential backoff for the Data Connect stream transport. Key changes include the addition of browser event listeners (online and visibilitychange) to trigger immediate reconnection attempts, the introduction of a backoff mechanism for unexpected disconnects, and logic to re-trigger active subscriptions and queries upon reconnection. Pending mutations are now explicitly rejected when a stream disconnects unexpectedly. Feedback focuses on preventing memory leaks by unregistering browser event listeners and ensuring that the idle timeout is cancelled during unexpected disconnects to avoid conflicting timers.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements automatic reconnection logic for the Data Connect stream transport, incorporating exponential backoff with jitter and integration with browser events like online/offline and visibility changes to trigger reconnections. It also introduces a dispose method for resource cleanup and refactors timeout-related naming for better clarity. A review comment correctly identifies a JSDoc error in the cleanupBrowserEventListeners method, which incorrectly describes the function as registering rather than unregistering event listeners.
| } | ||
|
|
||
| /** | ||
| * Register event listeners for browser-specific events like online/offline and visibility changes. |
There was a problem hiding this comment.
The JSDoc comment for cleanupBrowserEventListeners incorrectly states that it registers event listeners, but the method actually removes them. Please update the comment to reflect the correct behavior.
/**
* Unregister event listeners for browser-specific events like online/offline and visibility changes.
*/
Description
✨ Implemented intelligent reconnection with exponential backoff and lifecycle disposal for the Firebase Data Connect streaming transport.
Changes
AbstractDataConnectStreamTransport.onOnline,onVisibilityChange) for reconnect triggers.onStreamCloseto handle idle disconnects and cancel close timeouts.dispose()method to clean up listeners, timers, and close connection.transportManager.test.tsto simulate terminal failure usingrejectAllRequestsdirectly.Testing
streamTransport.test.ts.dispose()instreamTransport.test.ts.