feat: realtime lifecycle callbacks and isolated error handling (v27.1.0) - #134
Merged
Merged
Conversation
Adds Realtime.onError/onOpen/onClose callbacks, delivers message-handler exceptions via onError instead of crashing the coroutine, and isolates callbacks per connection (cleared on disconnect). Bumps android SDK to 27.1.0.
Greptile SummaryThe PR adds public realtime open, close, and error callbacks and routes message-processing exceptions through the error callback. It also clears lifecycle callbacks during disconnect and documents the change as version 27.1.0.
Confidence Score: 4/5The PR should not merge until lifecycle callbacks are stored per Realtime connection rather than shared globally. The new companion-scoped callback lists allow one Realtime instance to receive or erase another instance's lifecycle registrations; the broad Throwable catch is an additional non-blocking exception-boundary concern. Files Needing Attention: library/src/main/java/io/appwrite/services/Realtime.kt Important Files Changed
Prompt To Fix All With AI### Issue 1
library/src/main/java/io/appwrite/services/Realtime.kt:54-56
**Callback registries cross connections**
If an application creates multiple `Realtime` instances, their lifecycle registrations share these companion-object lists, so one connection dispatches another connection's callbacks and disconnecting either instance clears callbacks for both.
### Issue 2
library/src/main/java/io/appwrite/services/Realtime.kt:443-445
**Throwable catch suppresses termination**
Catching `Throwable` around parsing and application callback dispatch also absorbs cancellation signals and fatal JVM errors, reporting them as ordinary realtime errors and obscuring termination semantics after a non-recoverable failure.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "feat: add realtime lifecycle callbacks a..." | Re-trigger Greptile |
HarshMN2345
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the realtime error-handling fix from sdk-generator#1857 to the Android SDK.
What's Changed
Realtime.onError,onOpen, andonCloselifecycle callbacksonErrorinstead of crashing the coroutineonMessagenow wraps parsing/dispatch in a try/catch that reports failures throughdispatchError(with theAppwriteExceptioncode when available).onOpen/onClosing/onFailuredispatch the corresponding lifecycle callbacks, and the callback lists are cleared on disconnect to prevent leakage across connections.Version is release-tag driven (
SDK_VERSION); changelog bumped to 27.1.0.