From 13b041ce5d960ddfd32ede6057645eb757def8ac Mon Sep 17 00:00:00 2001 From: Elijah Date: Thu, 13 Jun 2024 06:16:02 +0000 Subject: [PATCH] make sure events are not queued for server side events particularly ones that call queueEvents(clear_local_storage, clear_cookies, remove_local_storage, remove_cookies) when the app is stateless(no ws) --- reflex/.templates/web/utils/state.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reflex/.templates/web/utils/state.js b/reflex/.templates/web/utils/state.js index 59c25cd16..642ae08ca 100644 --- a/reflex/.templates/web/utils/state.js +++ b/reflex/.templates/web/utils/state.js @@ -281,6 +281,12 @@ export const applyRestEvent = async (event, socket) => { * @param socket The socket object to send the event on. */ export const queueEvents = async (events, socket) => { + + // Only proceed if the socket is up, otherwise we throw the event into the void + if (!socket) { + return; + } + event_queue.push(...events); await processEvent(socket.current); };