From a18f5de0fc90c08aa2689d1d3c1aba11ea211947 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Tue, 30 Mar 2021 18:32:37 -0400 Subject: [PATCH] collab_client: Defer sending messages until connected This avoids filling the server logs with "Dropping pre-CLIENT_READY message" error messages. --- src/static/js/collab_client.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index 12185aeb2..15ef38cf9 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -167,7 +167,8 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad) handleUserChanges(); }; - const sendMessage = (msg) => { + const sendMessage = async (msg) => { + await connectedGate; getSocket().json.send( { type: 'COLLABROOM', @@ -326,7 +327,7 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad) userSet[userId] = userInfo; tellAceActiveAuthorInfo(userInfo); if (!getSocket()) return; - sendMessage( + await sendMessage( { type: 'USERINFO_UPDATE', userInfo, @@ -398,8 +399,8 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad) return array; }; - const sendClientMessage = (msg) => { - sendMessage( + const sendClientMessage = async (msg) => { + await sendMessage( { type: 'CLIENT_MESSAGE', payload: msg,