Fix mem leak (#916)

* Fix mem leak

* Fix cross-platform, fix no error logging
This commit is contained in:
Alex Netsch
2025-10-03 09:46:44 +01:00
committed by GitHub
parent 0f835e9730
commit 8dc297c521
3 changed files with 84 additions and 34 deletions

View File

@@ -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) {