Skip to content

Commit 5add4ba

Browse files
Dadzemovicclaude
andauthored
Fix socket reference shape mismatch in queueEvents (#6094)
* Fix socket shape mismatch in queueEvents Add resolveSocket() helper to handle both ref objects ({ current: Socket }) and raw sockets, fixing a bug where queueEvents would call socket.current on an already-unwrapped socket, causing processEvent to bail out. * Address feedback and add JSDoc comment Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 22bf804 commit 5add4ba

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

reflex/.templates/web/utils/state.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,16 @@ export const applyRestEvent = async (event, socket, navigate, params) => {
446446
return eventSent;
447447
};
448448

449+
/**
450+
* Resolve a socket reference to the actual socket object.
451+
* Handles both ref objects ({ current: Socket }) and raw sockets.
452+
* @param socket Either a ref object or raw socket.
453+
* @returns The actual socket object.
454+
*/
455+
const resolveSocket = (socket) => {
456+
return socket?.current ?? socket;
457+
};
458+
449459
/**
450460
* Queue events to be processed and trigger processing of queue.
451461
* @param events Array of events to queue.
@@ -471,7 +481,7 @@ export const queueEvents = async (
471481
];
472482
}
473483
event_queue.push(...events.filter((e) => e !== undefined && e !== null));
474-
await processEvent(socket.current, navigate, params);
484+
await processEvent(resolveSocket(socket), navigate, params);
475485
};
476486

477487
/**

0 commit comments

Comments
 (0)