mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-05 19:01:03 +00:00
Don't clean up a documents event listener until after the socket has disconnected on error
This commit is contained in:
parent
36c8c197e1
commit
345d38c28d
2 changed files with 9 additions and 4 deletions
|
@ -52,6 +52,7 @@ define [], () ->
|
|||
"force new connection": true
|
||||
|
||||
@ide.socket.on "connect", () =>
|
||||
sl_console.log "[socket.io connect] Connected"
|
||||
@connected = true
|
||||
@ide.pushEvent("connected")
|
||||
|
||||
|
@ -61,8 +62,6 @@ define [], () ->
|
|||
if @$scope.state.loading
|
||||
@$scope.state.load_progress = 70
|
||||
|
||||
sl_console.log "[socket.io connect] Connected"
|
||||
|
||||
setTimeout(() =>
|
||||
@joinProject()
|
||||
, 100)
|
||||
|
@ -75,6 +74,7 @@ define [], () ->
|
|||
|
||||
|
||||
@ide.socket.on 'disconnect', () =>
|
||||
sl_console.log "[socket.io disconnect] Disconnected"
|
||||
@connected = false
|
||||
@ide.pushEvent("disconnected")
|
||||
|
||||
|
|
|
@ -198,6 +198,7 @@ define [
|
|||
@leave()
|
||||
|
||||
_onDisconnect: () ->
|
||||
sl_console.log '[onDisconnect] disconnecting'
|
||||
@connected = false
|
||||
@joined = false
|
||||
@doc?.updateConnectionState "disconnected"
|
||||
|
@ -253,7 +254,7 @@ define [
|
|||
else
|
||||
# It's possible that this instance has error, and the doc has been reloaded.
|
||||
# This creates a new instance in Document.openDoc with the same id. We shouldn't
|
||||
# clear it because it's not use.
|
||||
# clear it because it's not this instance.
|
||||
sl_console.log "[_cleanUp] New instance of (#{@doc_id}) created. Not removing"
|
||||
@_unBindFromEditorEvents()
|
||||
@_unBindFromSocketEvents()
|
||||
|
@ -296,5 +297,9 @@ define [
|
|||
console.error "ShareJS error", error, meta
|
||||
ga?('send', 'event', 'error', "shareJsError", "#{error.message} - #{@ide.socket.socket.transport.name}" )
|
||||
@doc?.clearInflightAndPendingOps()
|
||||
@_cleanUp()
|
||||
@trigger "error", error, meta
|
||||
# The clean up should run after the error is triggered because the error triggers a
|
||||
# disconnect. If we run the clean up first, we remove our event handlers and miss
|
||||
# the disconnect event, which means we try to leaveDoc when the connection comes back.
|
||||
# This could intefere with the new connection of a new instance of this document.
|
||||
@_cleanUp()
|
||||
|
|
Loading…
Reference in a new issue