-
Notifications
You must be signed in to change notification settings - Fork 562
SnapshotRefresher creation and unit tests #26103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors snapshot refresh functionality by extracting it from SerializedStateManager into a new dedicated SnapshotRefresher class, improving separation of concerns and maintainability. The PR includes comprehensive unit tests for the new class.
Key changes:
- Extracted
SnapshotRefresherclass to manage periodic snapshot refresh operations with configurable timing - Added comprehensive unit test coverage (793 lines) for
SnapshotRefresherincluding edge cases, disposal, timer management, and error handling - Refactored
SerializedStateManagerto delegate snapshot refresh responsibilities toSnapshotRefresher
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| packages/loader/container-loader/src/snapshotRefresher.ts | New class that encapsulates snapshot refresh logic including timer management, promise tracking, and refresh orchestration |
| packages/loader/container-loader/src/test/snapshotRefresher.spec.ts | Comprehensive unit tests for SnapshotRefresher covering constructor, timer management, refresh flows, disposal, and group ID snapshots |
| packages/loader/container-loader/src/serializedStateManager.ts | Refactored to use SnapshotRefresher for snapshot refresh operations, removing duplicate code and delegating refresh responsibilities |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@dannimad please do not assign PRs to me. it breaks my notification settings |
| this.snapshotInfo = this.latestSnapshot; | ||
| this.latestSnapshot = undefined; | ||
| this.refreshTimer?.restart(); | ||
| this.snapshotRefresher?.clearLatestSnapshot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these don't seem equivalent, and its not clear why it is being changed. generally, we should avoid mixing refactoring with behavior changes, as it makes it hard to review and detect un-intended behavior changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clearLatestSnapshot is the equivalent of this.latestSnapshot = undefined, we're just clearing snapshotRefresher copy as well. I remove refreshTimer.restart() given that we will restart that timer right after onSnapshotRefreshed inside the refresher. I agree it is not clear to see but this is not a behavior change.
This PR refactors snapshot refresh functionality by extracting it from SerializedStateManager into a new dedicated SnapshotRefresher class, improving separation of concerns,maintainability and testing. Current e2e snapshot refresh tests are disabled due to flakiness so this PR adds back some test coverage for those scenarios.