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
- Clone this project, https://gitlab.com/gitlab-org/gitter/halley
- Run
npm installandnpm link
- Run
- Clone
gitter-realtime-client, https://gitlab.com/gitlab-org/gitter/realtime-client- Run
npm install,npm link, andnpm link halley
- Run
- In the
webapp, runnpm link gitter-realtime-client - Add the feature toggle,
node ./scripts/utils/feature-toggle.js --name vue-left-menu --description "Left menu using Vue (alpha)" - Enable the feature toggle
- Setup the debug logging in your browser,
window.localStorage.debug = 'halley:pool' - 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 reevaulatewhich this MR adds the functionality for
- You will probably see
- If you want to verify things work without the debug logging, open the network panel, switch to the
WSfilter, open thews://localhost:5000/bayeuxrequest. 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 🤖