Skip to content

🐛 Bug Report: RealtimeSubscription not being closed properly #83

@redarflap

Description

@redarflap

👟 Reproduction steps

Close a RealtimeSubscription.
Create and assign a new subscription.

subscription = realtime.subscribe([channels]);
await subscription.close();
// Inserting a delay here fixes the issue to some degree
subscription = null;

subscription = realtime.subscribe([channels]);
subscription.stream.listen(listener);

👍 Expected behavior

Only one connection and subscription stream should be active.

👎 Actual Behavior

The old StreamController of the subscription remains active next to the new subscription.
This leads to two simultanuously open subscriptions and two open connections to the server.
Every new event gets delivered to the listener twice.

A delay between closing and overwriting the subscription variable fixes the problem with the duplicate connections.

Update:
Also seeing a lot of null access exceptions coming from this line:
_channels[channel]!.remove(controller);

as well as:
Unhandled Exception: AppwriteException: null, Missing channels (1008)

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

Linux

🧱 Your Environment

sdk-for-flutter 6.0.0 on Android

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions