diff --git a/services/web/public/src/ide/connection/ConnectionManager.js b/services/web/public/src/ide/connection/ConnectionManager.js index 7f67f51797..8de0b3edc0 100644 --- a/services/web/public/src/ide/connection/ConnectionManager.js +++ b/services/web/public/src/ide/connection/ConnectionManager.js @@ -105,7 +105,7 @@ define([], function() { // handle network-level websocket errors (e.g. failed dns lookups) - this.ide.socket.on('error', err => { + let connectionErrorHandler = err => { sl_console.log('socket.io error', err) if (this.wsUrl && !window.location.href.match(/ws=fallback/)) { // if we tried to load a custom websocket location and failed @@ -118,13 +118,16 @@ define([], function() { "Unable to connect, please view the connection problems guide to fix the issue.") }) } - }) + } + this.ide.socket.on('error', connectionErrorHandler) // The "connect" event is the first event we get back. It only // indicates that the websocket is connected, we still need to // pass authentication to join a project. this.ide.socket.on('connect', () => { + // remove connection error handler when connected, avoid unwanted fallbacks + this.ide.socket.removeListener('error', connectionErrorHandler) return sl_console.log('[socket.io connect] Connected') })