ADFA-4010: close indexing services on background thread#1308
ADFA-4010: close indexing services on background thread#1308itsaky-adfa wants to merge 3 commits into
Conversation
Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIndexingServiceManager's shutdown behavior is enhanced to close all registered services concurrently with per-service timeouts, await their completion, then cancel remaining in-flight work. Coroutine helpers and a 10-second timeout constant are added. ProjectManagerImpl's import is updated to reference the modified manager. ChangesGraceful service shutdown with timeouts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lsp/indexing/src/main/kotlin/org/appdevforall/codeonthego/indexing/service/IndexingServiceManager.kt (1)
143-157:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFinish async close work before clearing manager state.
Lines 153-157 run immediately after the jobs are scheduled, not after they finish. That lets
service.close()raceregistry.close()and makes the final shutdown log fire too early.Suggested fix
override fun close() { log.info("Shutting down indexing services") + initialized = false @@ scope.launch { runCatching { joinAll(*cancellationJobs.toTypedArray()) } .onFailure { err -> log.error("Failed to close indexing services", err) } // Cancel in-flight work scope.coroutineContext.cancelChildren() + + services.clear() + registry.close() + log.info("Indexing services shut down") } - - services.clear() - registry.close() - initialized = false - - log.info("Indexing services shut down") }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lsp/indexing/src/main/kotlin/org/appdevforall/codeonthego/indexing/service/IndexingServiceManager.kt` around lines 143 - 157, The shutdown schedules a coroutine with scope.launch but then immediately clears state (services.clear, registry.close, initialized=false) and logs shutdown before the async work finishes; change the logic to wait for the launched coroutine to complete before mutating state—either by making the surrounding function suspend and using runCatching { joinAll(*cancellationJobs.toTypedArray()); scope.coroutineContext.cancelChildren() } directly, or by capturing the Job returned from scope.launch (the launch call around joinAll) and calling job.join() (or awaiting it in a runBlocking) before calling services.clear, registry.close, setting initialized = false and logging; ensure the join/await happens on the same coroutine scope so service.close()/registry.close() cannot race with state clearing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@lsp/indexing/src/main/kotlin/org/appdevforall/codeonthego/indexing/service/IndexingServiceManager.kt`:
- Around line 130-136: The catch block inside the
withTimeoutOrNull(SERVICE_CLOSE_TIMEOUT) around service.close() is catching
CancellationException and masking timeout cancellations; update the exception
handling in IndexingServiceManager (the withTimeoutOrNull block that calls
service.close() and logs via log.debug/log.error) to rethrow
CancellationException (or specifically catch CancellationException first and
throw it) and only handle other exceptions (e.g., Exception) for logging, so a
timeout cancellation propagates as intended to the timeout path.
---
Outside diff comments:
In
`@lsp/indexing/src/main/kotlin/org/appdevforall/codeonthego/indexing/service/IndexingServiceManager.kt`:
- Around line 143-157: The shutdown schedules a coroutine with scope.launch but
then immediately clears state (services.clear, registry.close,
initialized=false) and logs shutdown before the async work finishes; change the
logic to wait for the launched coroutine to complete before mutating
state—either by making the surrounding function suspend and using runCatching {
joinAll(*cancellationJobs.toTypedArray());
scope.coroutineContext.cancelChildren() } directly, or by capturing the Job
returned from scope.launch (the launch call around joinAll) and calling
job.join() (or awaiting it in a runBlocking) before calling services.clear,
registry.close, setting initialized = false and logging; ensure the join/await
happens on the same coroutine scope so service.close()/registry.close() cannot
race with state clearing.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cf20a36b-6c35-4403-84c7-b4b729134cf7
📒 Files selected for processing (2)
lsp/indexing/src/main/kotlin/org/appdevforall/codeonthego/indexing/service/IndexingServiceManager.ktsubprojects/projects/src/main/java/com/itsaky/androidide/projects/ProjectManagerImpl.kt
💤 Files with no reviewable changes (1)
- subprojects/projects/src/main/java/com/itsaky/androidide/projects/ProjectManagerImpl.kt
Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
jatezzz
left a comment
There was a problem hiding this comment.
Take a look at coderabbit comment.
Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
See ADFA-4010 for more details.