Skip to content

feat!: make RealtimeChannels.release() async and surface platform errors - #610

Open
SimonWoolf wants to merge 1 commit into
integration/v2from
release-throw-unless-detached
Open

SimonWoolf wants to merge 1 commit into
integration/v2from
release-throw-unless-detached

Conversation

@SimonWoolf

Copy link
Copy Markdown
Member

Implements RTS4c–e from spec 6.3.0 (ably/specification#557) for the next major version.

Breaking change: RealtimeChannels.release(name) now returns Future<void>. A realtime channel can only be released when it is INITIALIZED, DETACHED or FAILED. Releasing it in any other state no longer detaches it implicitly. Instead, the future completes with an AblyException (code 90011, statusCode 400) and the channel stays in the collection. Releasing a name that doesn't exist is a no-op.

Migration: await channel.detach(); and then await realtime.channels.release(name);. This is documented in UPDATING.md.

Implementation:

  • release() now awaits the platform call and only drops the Dart-side channel once the platform release succeeds. Previously the platform call was not awaited, so any error was lost and the Dart and platform channel collections diverged.
  • The state check is done by the platform SDKs, because RealtimeChannel.state on the Dart side can lag behind the platform channel.

Still to do: the Android and iOS handlers for releaseRealtimeChannel must pass the native release error back (Android: catch AblyException and call handleAblyException; iOS: return a FlutterError with the ARTErrorInfo). This depends on the ably-java and ably-cocoa next-major releases that implement RTS4e, which don't exist yet. With the current native pins (ably-android 1.6.0, Ably 1.2.53) release never fails.

The current-major docs change is in #609. Reference ably-js PRs: ably/ably-pubsub-js#2322 (deprecation) and ably/ably-pubsub-js#2323 (next major).

🤖 Generated with Claude Code

Spec 6.3.0 replaces RTS4a, under which release() detaches a channel that
is not already INITIALIZED, DETACHED or FAILED before removing it, with
RTS4c-e: release() of a channel in any other state must fail with error
90011 and leave the channel in place. That check is done by the
platform SDKs (ably-java, ably-cocoa) in their next major versions.

release() previously fired the platform call without awaiting it and
dropped the Dart-side channel unconditionally, so a platform error would
have been lost as an unhandled async error while the Dart and platform
collections diverged. It now returns a Future that completes with the
platform's AblyException, and only removes the Dart-side channel once the
platform release has succeeded. The state check is deliberately left to
the platform SDK, because RealtimeChannel.state is updated asynchronously
from platform events and so can lag behind the platform channel's state.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1d35e749-47b8-4884-bd3d-376e32af809b
📥 Commits

Reviewing files that changed from the base of the PR and between ea51456 and a3270c0.

📒 Files selected for processing (6)
  • UPDATING.md
  • example/lib/ui/realtime_sliver.dart
  • lib/src/common/src/channels.dart
  • lib/src/platform/src/realtime/realtime_channels.dart
  • test/mock_method_call_manager.dart
  • test/realtime/channels_test.dart
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch was successfully deployed

2 active deployments
staging/pull/610/dartdoc — a3270c0f Deployed Oct 9, 2026 by github-actions[bot]
staging/pull/610/features — a3270c0f Deployed Oct 9, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant