Skip to content

Realtime exception handler fix - #1857

Merged
ArnabChatterjee20k merged 9 commits into
mainfrom
realtime-exception-handler-fix
Aug 28, 2026
Merged

ArnabChatterjee20k merged 9 commits into
mainfrom
realtime-exception-handler-fix

Conversation

@ArnabChatterjee20k

Copy link
Copy Markdown
Member

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds Android lifecycle callback dispatching and Flutter policy-violation error delivery, together with cross-runtime realtime error coverage.

  • Adds Android open, close, and error callback APIs with exception-isolated dispatch.
  • Routes Flutter policy-violation frames to subscription error streams.
  • Extends the mock realtime protocol and end-to-end fixtures with a deterministic error scenario.

Confidence Score: 3/5

The PR is not yet safe to merge because Android lifecycle callbacks remain shared across Realtime instances, preserving both callback leakage and wrong-instance delivery.

The reply states that the callback lists were moved to instance fields, but the current template still declares them inside the companion object; consequently, lifecycle events are dispatched across instances and disconnecting one instance clears callbacks registered by others.

Files Needing Attention: templates/android/library/src/main/java/io/package/services/Realtime.kt.twig

Important Files Changed

Filename Overview
templates/android/library/src/main/java/io/package/services/Realtime.kt.twig Adds exception-isolated lifecycle callbacks, but the callback collections remain companion-owned and therefore preserve the previously reported cross-instance ownership failures.
templates/flutter/lib/src/realtime_mixin.dart.twig Delivers policy-violation exceptions to active subscription streams instead of throwing from the message handler.
mock-server/src/Utopia/Realtime/Protocol.php Adds a deterministic policy-violation frame for subscriptions to the test-only error channel.
tests/e2e/Base.php Adds the realtime error marker to the shared ordered end-to-end result contract.

Reviews (4): Last reviewed commit: "fix(kotlin): share realtime lifecycle ca..." | Re-trigger Greptile

Comment thread templates/android/library/src/main/java/io/package/services/Realtime.kt.twig Outdated
Comment thread templates/android/library/src/main/java/io/package/services/Realtime.kt.twig Outdated
Comment on lines +54 to +69
private val onErrorCallbacks = CopyOnWriteArrayList<(Throwable?, Int?) -> Unit>()
private val onCloseCallbacks = CopyOnWriteArrayList<() -> Unit>()
private val onOpenCallbacks = CopyOnWriteArrayList<() -> Unit>()
}

fun onError(callback: (error: Throwable?, statusCode: Int?) -> Unit) {
onErrorCallbacks.add(callback)
}

fun onClose(callback: () -> Unit) {
onCloseCallbacks.add(callback)
}

fun onOpen(callback: () -> Unit) {
onOpenCallbacks.add(callback)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these added now? Was it missed earlier?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes was a regression

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