appwrite / sdk-for-web

[READ-ONLY] Official Appwrite Web SDK 🧑

Home Page:https://appwrite.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ› Bug Report: Realtime ws unsubscribe does not work as expected

xuelink opened this issue Β· comments

commented

πŸ‘Ÿ Reproduction steps

unsubscribe does not work as expected for the following code block

  startListener() {
    if (!this.listenerFn) {
      this.listenerFn = this.notification.connect();
    }
  }

  unsubscribeListener() {
    // Stop listening to notifications
    if (this.listenerFn) {
      this.listenerFn();
      console.log('Notification Service stopped');
    }

doc ref:

import { Client } from "appwrite";

const client = new Client()
    .setEndpoint('https://cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>');

const unsubscribe = client.subscribe('files', response => {
    // Callback will be executed on changes for all files.
    console.log(response);
});

// Closes the subscription.
unsubscribe();

demo video:

πŸ‘ Expected behavior

it should close the websocket totally. i can see the network tab of inspector

πŸ‘Ž Actual Behavior

when i call unsubscribe, it doesnt trigger to and after logout it continues to listen.

🎲 Appwrite version

Different version (specify in environment)

πŸ’» Operating system

MacOS

🧱 Your Environment

appwrite version 1.4.13
sdk for web "appwrite": "^13.0.0",

πŸ‘€ 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?

@behics, thanks for creating this issue! πŸ™πŸΌ Since we already have appwrite/appwrite#7584. It would be good to just use that 1 issue. Please make sure to add a πŸ‘πŸΌ to that issue.