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