Hi,
I just encountered an issue while using your "useWs" implementation.
If a component using "useWs" hook unmount, the "onClose" handler is not called.
This is due to the following cleanup code : https://github.com/cloudflare/partykit/blob/main/packages/partysocket/src/use-handlers.ts#L35-L40
The event "close" event is no longer listened to, so if the websocket is closed due to an unmount, the "onClose" handler is never called. The only current solution to this problem is to create a custom cleanup function on unmount which is not ideal as the hook "useWs" already provides one.
Here is a minimal reproduction :
https://github.com/Yovach/partykit-bug-reproduction-unmount-close
Thanks
Hi,
I just encountered an issue while using your "useWs" implementation.
If a component using "useWs" hook unmount, the "onClose" handler is not called.
This is due to the following cleanup code : https://github.com/cloudflare/partykit/blob/main/packages/partysocket/src/use-handlers.ts#L35-L40
The event "close" event is no longer listened to, so if the websocket is closed due to an unmount, the "onClose" handler is never called. The only current solution to this problem is to create a custom cleanup function on unmount which is not ideal as the hook "useWs" already provides one.
Here is a minimal reproduction :
https://github.com/Yovach/partykit-bug-reproduction-unmount-close
Thanks