appwrite icon indicating copy to clipboard operation
appwrite copied to clipboard

🐛 Bug Report: Web SDK fails to disconnect when the unsubscribe function is returned

Open collinmyers opened this issue 1 year ago • 2 comments

👟 Reproduction steps

subscribe

useFocusEffect This occurs with both the useEffect and useFocusEffect hooks. Upon subscribing to the real-time event from the database, you receive a function within the logic to eventually unsubscribe. When navigating away from the page, the components in the return statement of the useEffect or useFocusEffect should execute. The function returned from the subscribe operation should disconnect the real-time connection.

👍 Expected behavior

Upon unmounting the component, the unsubscribe function should terminate the real-time connection.

👎 Actual Behavior

The real-time connection remains active even after the component has been unmounted.

🎲 Appwrite version

Version 1.4.x

💻 Operating system

Windows

🧱 Your Environment

I'm utilizing Appwrite v1.4.13, along with SDK version 13.0.1, in a self-hosted environment. This setup is integrated within a React Native application.

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

  • [X] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

collinmyers avatar Feb 13 '24 19:02 collinmyers

@collinmyers, thanks for raising this issue! 🙏🏼 This definitely looks like a bug in the SDK. It doesn't look the the SDK is closing the websocket because of this code: https://github.com/appwrite/sdk-for-web/blob/ca8cb1d9f2c0393ec99c7d5cb50f3be543987918/src/client.ts#L211

Related Discord thread: https://discord.com/channels/564160730845151244/1201047679338295429

stnguyen90 avatar Feb 13 '24 20:02 stnguyen90

Waiting for update about this issue, it was really headache for my chat app 🚀

xuelink avatar Mar 08 '24 13:03 xuelink

Any updates here ?

xuelink avatar Mar 28 '24 17:03 xuelink

@xuelink https://github.com/ZachHandley/AppwriteReactRealtimeTest can you fork this and give me a reproducible example perchance -- this is 1.5, but I imported the built SDK right in and I don't think the Realtime changed in between, but I can test it on 1.4 if there's an issue

Can't seem to get it to break myself though that's a really simple example

ZachHandley avatar Apr 16 '24 03:04 ZachHandley

@xuelink https://github.com/ZachHandley/AppwriteReactRealtimeTest can you fork this and give me a reproducible example perchance -- this is 1.5, but I imported the built SDK right in and I don't think the Realtime changed in between, but I can test it on 1.4 if there's an issue

Can't seem to get it to break myself though that's a really simple example

@ZachHandley Thank you for your interest here but im not comfortable with react well, so maybe @collinmyers can do it for reproduction for you to understand easily.

This closed issue is the same issue as reproduced with angular: https://github.com/appwrite/sdk-for-web/issues/91

I just bypassed this issue by forking sdk and commenting this related line temporarily. ref

xuelink avatar Apr 16 '24 11:04 xuelink

Fixed in https://github.com/appwrite/sdk-for-web/pull/93

stnguyen90 avatar Apr 17 '24 19:04 stnguyen90