Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3486347
D10973.id36736.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D10973.id36736.diff
View Options
diff --git a/lib/identity-search/identity-search-context.js b/lib/identity-search/identity-search-context.js
--- a/lib/identity-search/identity-search-context.js
+++ b/lib/identity-search/identity-search-context.js
@@ -38,6 +38,10 @@
const socket = React.useRef<?WebSocket>(null);
const heartbeatTimeoutID = React.useRef<?TimeoutID>();
+ const previousAuthMessage = React.useRef<?AuthMessage>(authMessage);
+ const authMessageChanged = authMessage !== previousAuthMessage.current;
+ previousAuthMessage.current = authMessage;
+
const stopHeartbeatTimeout = React.useCallback(() => {
if (heartbeatTimeoutID.current) {
clearTimeout(heartbeatTimeoutID.current);
@@ -53,7 +57,16 @@
}, identitySearchHeartbeatTimeout);
}, [stopHeartbeatTimeout]);
+ const isSocketActive =
+ socket.current?.readyState === WebSocket.OPEN ||
+ socket.current?.readyState === WebSocket.CONNECTING;
+
React.useEffect(() => {
+ if ((!authMessage || authMessageChanged) && isSocketActive) {
+ socket.current?.close();
+ return;
+ }
+
if (connected || !authMessage) {
return;
}
@@ -129,7 +142,14 @@
};
socket.current = identitySearchSocket;
- }, [connected, authMessage, resetHeartbeatTimeout, stopHeartbeatTimeout]);
+ }, [
+ connected,
+ authMessage,
+ resetHeartbeatTimeout,
+ stopHeartbeatTimeout,
+ authMessageChanged,
+ isSocketActive,
+ ]);
const addListener = React.useCallback(
(listener: IdentitySearchSocketListener) => {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 4:40 AM (21 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675310
Default Alt Text
D10973.id36736.diff (1 KB)
Attached To
Mode
D10973: [lib] Check for previous auth message and websocket connection state in identity search context provider
Attached
Detach File
Event Timeline
Log In to Comment