mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #1523 from sharelatex/bg-avoid-unwanted-fallback-on-network-errors
avoid fallback to old websocket if initial connection succeeded GitOrigin-RevId: 1b3f38d0a0f4889b9a15fa071de90a0a9c9a5699
This commit is contained in:
@@ -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 <u><a href='/learn/Kb/Connection_problems'>connection problems guide</a></u> 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')
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user