appwrite / sdk-for-web

[READ-ONLY] Official Appwrite Web SDK 🧑
https://appwrite.io
BSD 3-Clause "New" or "Revised" License
273 stars 59 forks source link

πŸ› Bug Report: Realtime/Websocket stuck with previous user after new user has logined #24

Closed mcchin closed 2 years ago

mcchin commented 2 years ago

πŸ‘Ÿ Reproduction steps

Config/Setup:

To reproduce:

  1. Login as User A , e.g. sdk.account.createSession(User A email, User A password)

  2. At a React page, using WebSDK to subscribe to a channel like so

    useEffect(() => {
    const unsubscribe = sdk.subscribe(`collections.COLLECTION_ID.documents`,
      res => {
        console.log('realtime response', res)
      }
    )
    
    return () => {
      unsubscribe()
    }
    }, [])
  3. Update any of the documents on the said collection from Appwrite Console, and I can noticed data is received, and channel/subscription callback is executed

  4. User A logout, unsubscribe() is fired, and then User A is logout like so sdk.account.deleteSession('current') / sdk.account.deleteSession(session_id)

  5. At the same browser tab, User B login, e.g. sdk.account.createSession(User B email, User B password), and visit the same page, so step 2 above is executed as well NOTE: Don't refresh browser page, if you have refreshed browser page you can't reproduce the issue

  6. Update any of the documents on the said collection from Appwrite Console, and I can noticed data is received, and channel/subscription callback is executed, which is not expected behaviour as only User A has read permission, not User B

πŸ‘ Expected behavior

I should not receive any channel/subscription callback when I login as User B

πŸ‘Ž Actual Behavior

I receive channel/subscription callback when I login as User B, but User B doesn't have any read permission on the subscribed data collection (Where the callback response data is for User A)

🎲 Appwrite version

Different version (specify in environment)

πŸ’» Operating system

Linux

🧱 Your Environment

πŸ‘€ Have you spent some time to check if this issue has been raised before?

🏒 Have you read the Code of Conduct?

lohanidamodar commented 2 years ago

@mcchin Thank you for reporting the issue with such details. We will look into the issue and get back to you.

TorstenDittmann commented 2 years ago

I'll be closing this in favour of #25