chore: Extract server recovery tracking from controller#1552
Conversation
Move recovery task tracking and retry backoff out of the server controller while preserving the public RecoveryTask surface and retry ordering.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
📝 WalkthroughWalkthroughRecovery scheduling and retry/backoff logic previously implemented inside ChangesRecovery tracking service extraction
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Controller as UnityCliLoopServerControllerService
participant Tracker as UnityCliLoopServerRecoveryTrackingService
participant Repo as ISessionFlagsRepository
Controller->>Tracker: ScheduleStartupRecovery(restoreServerState)
Tracker-->>Controller: RecoveryTask
Controller->>Tracker: ScheduleTrackedRecovery(recoveryAction)
loop retry with backoff
Tracker->>Repo: GetIsServerManuallyStopped()
alt manually stopped
Tracker-->>Controller: abandon retries
else retries exceeded
Tracker->>Repo: ClearServerSession()
Tracker-->>Controller: throw InvalidOperationException
end
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
1 issue found across 6 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerRecoveryTrackingService.cs">
<violation number="1" location="Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerRecoveryTrackingService.cs:168">
P2: Recovery failures can produce an extra unobserved fault from the fire-and-forget cleanup task, which may trigger noisy `UnobservedTaskException` handling and duplicate error surfacing. This happens because `ClearTrackedRecoveryWhenCompleteAsync` rethrows `recoveryTask` faults even though its result is intentionally discarded.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| await recoveryTask; | ||
| } | ||
| finally | ||
| { | ||
| if (ReferenceEquals(_currentRecoveryTask, recoveryTask)) | ||
| { | ||
| _currentRecoveryTask = null; | ||
| } | ||
| } |
There was a problem hiding this comment.
P2: Recovery failures can produce an extra unobserved fault from the fire-and-forget cleanup task, which may trigger noisy UnobservedTaskException handling and duplicate error surfacing. This happens because ClearTrackedRecoveryWhenCompleteAsync rethrows recoveryTask faults even though its result is intentionally discarded.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At Packages/src/Editor/Infrastructure/Server/UnityCliLoopServerRecoveryTrackingService.cs, line 168:
<comment>Recovery failures can produce an extra unobserved fault from the fire-and-forget cleanup task, which may trigger noisy `UnobservedTaskException` handling and duplicate error surfacing. This happens because `ClearTrackedRecoveryWhenCompleteAsync` rethrows `recoveryTask` faults even though its result is intentionally discarded.</comment>
<file context>
@@ -0,0 +1,179 @@
+
+ try
+ {
+ await recoveryTask;
+ }
+ finally
</file context>
| await recoveryTask; | |
| } | |
| finally | |
| { | |
| if (ReferenceEquals(_currentRecoveryTask, recoveryTask)) | |
| { | |
| _currentRecoveryTask = null; | |
| } | |
| } | |
| await recoveryTask; | |
| } | |
| catch | |
| { | |
| // Recovery failure is surfaced by the original recoveryTask returned to callers. | |
| } | |
| finally | |
| { | |
| if (ReferenceEquals(_currentRecoveryTask, recoveryTask)) | |
| { | |
| _currentRecoveryTask = null; | |
| } | |
| } |
Summary
User Impact
Changes
Verification
dist/darwin-arm64/uloop compile --project-path "$(git rev-parse --show-toplevel)"-> 0 errors / 0 warningsdist/darwin-arm64/uloop run-tests --project-path "$(git rev-parse --show-toplevel)" --test-mode EditMode --filter-type regex "(DomainReloadRecoveryUseCaseTests|UnityCliLoopServerControllerRecoveryTests|UnityCliLoopServerStartupProtectionTests|UnityCliLoopBridgeServerShutdownTests|JsonRpcHeartbeatTests|UnityCliLoopServerLifecycleRegistryServiceTests|ServerLifecycleContractTests|UnityCliLoopFirstPartyServerLifecycleBindingTests|JsonRpcProcessorCliVersionGateTests|OnionAssemblyDependencyTests)"-> 141/141 passed