Skip to content

Fix halley preferring long-polling if websockets doesn't connect quick enough

Fix halley preferring long-polling if websocket doesn't connect quick enough. This MR will reevaluate the available transports after one connects.

I only noticed this behavior when the new vue-left-menu was enabled and I guess the timing is just different enough to notice this now. Details in https://gitlab.com/gitlab-org/gitter/webapp/issues/2175

Fix https://gitlab.com/gitlab-org/gitter/webapp/issues/2175

halley:pool _reselect: ["websocket","long-polling"] +0ms
halley:pool Selected transport long-polling +176ms
halley:pool _reselect: ["long-polling"] +3ms
halley:pool Selected transport long-polling +5ms
halley:pool _reselect: ["long-polling"] +231ms
halley:pool Selected transport long-polling +2ms
halley:pool _reselect: ["websocket","long-polling"] +27ms
halley:pool Selected transport long-polling +1ms
halley:pool _reselect: "websocket" is now connected so we are going to reevaulate +1s
halley:pool _reselect: ["websocket","long-polling"] +1ms
halley:pool Selected transport websocket +2ms

Testing strategy

There are unit tests added in this MR for the new functionality. But to try this in the real-world, here are some instructions

  1. Clone this project, https://gitlab.com/gitlab-org/gitter/halley
    1. Run npm install and npm link
  2. Clone gitter-realtime-client, https://gitlab.com/gitlab-org/gitter/realtime-client
    1. Run npm install, npm link, and npm link halley
  3. In the webapp, run npm link gitter-realtime-client
  4. Add the feature toggle, node ./scripts/utils/feature-toggle.js --name vue-left-menu --description "Left menu using Vue (alpha)"
  5. Enable the feature toggle
  6. Setup the debug logging in your browser, window.localStorage.debug = 'halley:pool'
  7. Refresh the page and look for a consistent halley:pool Selected transport websocket
    • You will probably see _reselect: "websocket" is now connected so we are going to reevaulate which this MR adds the functionality for
  8. If you want to verify things work without the debug logging, open the network panel, switch to the WS filter, open the ws://localhost:5000/bayeux request. Then look at the messages tab. If there is stuff there, then things are working. You can send a message to see something flow in

Dev notes

See debug logging

window.localStorage.debug = 'halley:pool'
window.halleyReevaluate = () => {
  this.reevaluate();
}
Edited by 🤖 GitLab Bot 🤖

Merge request reports

Loading