ADFA-2081 | Force Gradle sync when project cache is missing#655
Conversation
prevents initialization failure by re-triggering project sync
Greptile OverviewGreptile SummaryChanged project initialization error handling to automatically retry with forced Gradle sync when cache read fails, instead of showing error to user. Key Changes:
Critical Issues:
Confidence Score: 1/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Activity as ProjectHandlerActivity
participant Manager as ProjectManagerImpl
participant BuildService as GradleBuildService
Note over Activity: Initial project open
Activity->>Activity: initializeProject(forceSync=false)
Activity->>BuildService: initializeProject(needsSync)
BuildService-->>Activity: InitializeResult.Success
Activity->>Activity: onProjectInitialized()
Activity->>Manager: readGradleBuild()
alt Cache file exists
Manager-->>Activity: Success(GradleBuild)
Activity->>Manager: setup(gradleBuild)
Activity->>Activity: postProjectInit(true)
else Cache file missing
Manager-->>Activity: Failure(error)
Activity->>Activity: initializeProject(forceSync=true)
Note over Activity: RISK: If cache still fails,<br/>infinite recursion occurs
Activity->>BuildService: initializeProject(needsSync=true)
BuildService-->>Activity: InitializeResult.Success
Activity->>Activity: onProjectInitialized()
Activity->>Manager: readGradleBuild()
Note over Activity: Loop continues if cache<br/>read still fails
end
|
| } | ||
|
|
||
| withContext(Dispatchers.Main) { postProjectInit(false, CACHE_READ_ERROR) } | ||
| withContext(Dispatchers.Main) { initializeProject(forceSync = true) } |
There was a problem hiding this comment.
logic: infinite recursion risk: if forced sync succeeds but cache read still fails, onProjectInitialized will call initializeProject(forceSync=true) again, creating infinite loop. need retry counter or max attempts check
| withContext(Dispatchers.Main) { initializeProject(forceSync = true) } | |
| // Prevent infinite retry loop - only retry once | |
| if (forceSync) { | |
| withContext(Dispatchers.Main) { postProjectInit(false, CACHE_READ_ERROR) } | |
| } else { | |
| withContext(Dispatchers.Main) { initializeProject(forceSync = true) } | |
| } |
| @@ -552,11 +552,8 @@ abstract class ProjectHandlerActivity : BaseEditorActivity() { | |||
| if (gradleBuildResult.isFailure) { | |||
| val error = gradleBuildResult.exceptionOrNull() | |||
| log.error("Failed to read project cache", error) | |||
There was a problem hiding this comment.
logic: removed error tracking: exception is no longer captured with Sentry.captureException(). cache read failures won't be tracked for monitoring
Context Used: Rule from dashboard - Use Sentry.captureException() to capture exceptions for error tracking and monitoring. (source)
|
DO NOT MERGE. This conflicts with #648 |
dara-abijo-adfa
left a comment
There was a problem hiding this comment.
Check Greptile's comment about the infinite recursion risk.
|
This PR will be closed, as it's a duplicate of #648 |
Description
This PR updates the project initialization flow to automatically trigger a Gradle sync when the project cache file is missing. This prevents initialization failures and ensures the IDE can recover gracefully without manual user intervention.
Details
The previous behavior treated the missing cache as a fatal error. Now, a forced
initializeProject(true)is executed on the main thread, allowing the Gradle Tooling server to regenerate the required cache.Screen.Recording.2025-11-21.at.4.57.42.PM.mov
Ticket
ADFA-2081
Observation
This improves robustness when opening newly created or externally modified projects.