only start the event loop when the socket is set or we're not stateful

This commit is contained in:
Masen Furer 2025-01-31 16:22:00 -08:00
parent 38d2ef721d
commit 4179ec9c49
No known key found for this signature in database
GPG Key ID: 2AE2BD5531FF94F4

View File

@ -839,7 +839,7 @@ export const useEventLoop = (
socket.current.disconnect(); socket.current.disconnect();
} }
}; };
}, [isBackendDisabled]); }, []);
// Main event loop. // Main event loop.
useEffect(() => { useEffect(() => {
@ -847,13 +847,15 @@ export const useEventLoop = (
if (!router.isReady) { if (!router.isReady) {
return; return;
} }
(async () => { if (socket.current || !isStateful()) {
// Process all outstanding events. (async () => {
while (event_queue.length > 0 && !event_processing) { // Process all outstanding events.
await processEvent(socket.current); while (event_queue.length > 0 && !event_processing) {
} await processEvent(socket.current);
})(); }
}); })();
}
}, [socket]);
// localStorage event handling // localStorage event handling
useEffect(() => { useEffect(() => {