Fix mem leak (#916)
* Fix mem leak * Fix cross-platform, fix no error logging
This commit is contained in:
@@ -154,7 +154,16 @@ export const useJsonPatchWsStream = <T>(
|
||||
|
||||
return () => {
|
||||
if (wsRef.current) {
|
||||
wsRef.current.close();
|
||||
const ws = wsRef.current;
|
||||
|
||||
// Clear all event handlers first to prevent callbacks after cleanup
|
||||
ws.onopen = null;
|
||||
ws.onmessage = null;
|
||||
ws.onerror = null;
|
||||
ws.onclose = null;
|
||||
|
||||
// Close regardless of state
|
||||
ws.close();
|
||||
wsRef.current = null;
|
||||
}
|
||||
if (retryTimerRef.current) {
|
||||
|
||||
Reference in New Issue
Block a user