We have noticed that users and channels were taking a long time to get created which was likely leading to the Socket URL has expired error we were seeing when connecting the Slack websocket. The user and room creation takes ~28secs in development however the window between getting the websocket URL and connecting to it is 30 seconds (cc. https://api.slack.com/methods/rtm.start, where “These URLs are only valid for 30 seconds, so connect quickly!“), which we might have easily gone over if we are in a busy node or during busy times where the responses might take longer than that to trickle in.
Moving the user creation and room creation to happen only once we secured the websocket connection, we also had to move the where the block is yielded so it does not try to process messages before the list of users and channels is built.
Also added more descriptive logging so we can see more details and timing into the different actions.
We have noticed that users and channels were taking a long time to get created which was likely leading to the
Socket URL has expired
error we were seeing when connecting the Slack websocket. The user and room creation takes ~28secs in development however the window between getting the websocket URL and connecting to it is 30 seconds (cc. https://api.slack.com/methods/rtm.start, where “These URLs are only valid for 30 seconds, so connect quickly!“), which we might have easily gone over if we are in a busy node or during busy times where the responses might take longer than that to trickle in.Moving the user creation and room creation to happen only once we secured the websocket connection, we also had to move the where the block is yielded so it does not try to process messages before the list of users and channels is built.
Also added more descriptive logging so we can see more details and timing into the different actions.