Fix various incorrect coroutine usage#1980
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request fixes incorrect coroutine usage across multiple polling and configuration components by properly handling CancellationException and removing unnecessary coroutine scopes. The changes ensure that coroutine cancellation is propagated correctly, which is critical for proper cleanup and resource management in Kotlin coroutines.
Changes:
- Added
CancellationExceptionre-throw logic in exception handlers to ensure proper coroutine cancellation propagation - Refactored
OpenGroupPollerManager.pollAllOpenGroupsOnce()to useasync/awaitAllinstead oflaunch/joinAllfor cleaner error propagation - Removed unnecessary
supervisorScopewrapper fromMessageSender.sendToSnodeDestination()since it doesn't launch child coroutines
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| ConfigUploader.kt | Added CancellationException checks in two catch blocks to properly propagate coroutine cancellation |
| Poller.kt | Added CancellationException check in TTL extension error handler to prevent swallowing cancellation |
| OpenGroupPollerManager.kt | Refactored polling logic to use async/awaitAll pattern and removed manual error handling in favor of exception propagation |
| OpenGroupPoller.kt | Wrapped polling operations in try-catch blocks with CancellationException checks to ensure proper error handling while preserving cancellation |
| MessageSender.kt | Removed unnecessary supervisorScope wrapper since the function doesn't launch child coroutines |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
app/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPoller.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPoller.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPoller.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/OpenGroupPoller.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Issues:
launchblock fromsupervisorScopesupervisorScope