Skip to content

feat: realtime lifecycle callbacks and isolated error handling (v27.1.0) - #134

Merged
ArnabChatterjee20k merged 1 commit into
mainfrom
feat/realtime-error-handling
Aug 28, 2026
Merged

feat: realtime lifecycle callbacks and isolated error handling (v27.1.0)#134
ArnabChatterjee20k merged 1 commit into
mainfrom
feat/realtime-error-handling

Conversation

@ArnabChatterjee20k

Copy link
Copy Markdown
Member

Ports the realtime error-handling fix from sdk-generator#1857 to the Android SDK.

What's Changed

  • Added: Realtime.onError, onOpen, and onClose lifecycle callbacks
  • Fixed: message-handler exceptions are delivered via onError instead of crashing the coroutine
  • Fixed: lifecycle callbacks are isolated per connection and cleared on disconnect

onMessage now wraps parsing/dispatch in a try/catch that reports failures through dispatchError (with the AppwriteException code when available). onOpen/onClosing/onFailure dispatch 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.

Scope is realtime-only — no other API surface changed. The e2e coverage for this fix lives in the sdk-generator repo (already merged in #1857); this repo carries no realtime e2e tests.

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-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown

Greptile Summary

The 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.

  • Adds thread-safe lifecycle callback registries and dispatch helpers.
  • Dispatches callbacks from WebSocket listener lifecycle and message-error paths.
  • Clears callback registrations during full realtime teardown.
  • Updates the changelog for the new realtime behavior.

Confidence Score: 4/5

The 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

Filename Overview
library/src/main/java/io/appwrite/services/Realtime.kt Adds realtime lifecycle/error callbacks, but companion-scoped registries violate per-connection isolation and the catch-all handler suppresses non-recoverable Throwables.
CHANGELOG.md Documents the 27.1.0 realtime callback and error-isolation changes accurately, although the implementation does not fully provide the stated per-connection isolation.

Fix all with Greploop Fix All in Claude Code Fix All in Codex

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

Comment thread library/src/main/java/io/appwrite/services/Realtime.kt
Comment thread library/src/main/java/io/appwrite/services/Realtime.kt
@ArnabChatterjee20k
ArnabChatterjee20k merged commit 8d4c2f5 into main Aug 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants