Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion reflex/.templates/web/utils/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,16 @@ export const applyRestEvent = async (event, socket, navigate, params) => {
return eventSent;
};

/**
* Resolve a socket reference to the actual socket object.
* Handles both ref objects ({ current: Socket }) and raw sockets.
* @param socket Either a ref object or raw socket.
* @returns The actual socket object.
*/
const resolveSocket = (socket) => {
return socket?.current ?? socket;
};

/**
* Queue events to be processed and trigger processing of queue.
* @param events Array of events to queue.
Expand All @@ -468,7 +478,7 @@ export const queueEvents = async (
];
}
event_queue.push(...events.filter((e) => e !== undefined && e !== null));
await processEvent(socket.current, navigate, params);
await processEvent(resolveSocket(socket), navigate, params);
};

/**
Expand Down