mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-11 07:45:12 +00: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:
parent
e78487922e
commit
1940e9b061
1 changed files with 5 additions and 2 deletions
|
@ -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')
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue