mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-28 11:31:55 +02:00
Resync after an op is not acknowledged rather than throwing an error
This commit is contained in:
@@ -87,6 +87,11 @@ define [
|
||||
wantToBeJoined: @wantToBeJoined
|
||||
update: update
|
||||
|
||||
if Math.random() < (@ide.disconnectRate or 0)
|
||||
console.log "Simulating disconnect"
|
||||
@ide.connectionManager.disconnect()
|
||||
return
|
||||
|
||||
if update?.doc == @doc_id and @doc?
|
||||
@doc.processUpdateFromServer update
|
||||
|
||||
@@ -163,6 +168,13 @@ define [
|
||||
doc_id: @doc_id
|
||||
op: op
|
||||
@trigger "op:acknowledged"
|
||||
@doc.on "op:timeout", (op) =>
|
||||
@ide.pushEvent "op:timeout",
|
||||
doc_id: @doc_id
|
||||
op: op
|
||||
@trigger "op:timeout"
|
||||
ga?('send', 'event', 'error', "op timeout", "Op was now acknowledged - #{ide.socket.socket.transport.name}" )
|
||||
@ide.connectionManager.reconnectImmediately()
|
||||
@doc.on "flush", (inflightOp, pendingOp, version) =>
|
||||
@ide.pushEvent "flush",
|
||||
doc_id: @doc_id,
|
||||
|
||||
@@ -98,7 +98,7 @@ define [
|
||||
v: update.v
|
||||
op_sent_at: new Date()
|
||||
timer = setTimeout () =>
|
||||
@_handleError new Error("Doc op was not acknowledged in time"), meta
|
||||
@trigger "op:timeout", update
|
||||
, @INFLIGHT_OP_TIMEOUT
|
||||
@_doc.inflightCallbacks.push () =>
|
||||
clearTimeout timer
|
||||
|
||||
@@ -33,6 +33,13 @@ define [
|
||||
e.preventDefault()
|
||||
@tryReconnect()
|
||||
@hideModal()
|
||||
|
||||
reconnectImmediately: () ->
|
||||
@disconnect()
|
||||
@tryReconnect()
|
||||
|
||||
disconnect: () ->
|
||||
@socket.disconnect()
|
||||
|
||||
showModalAndStartAutoReconnect: () ->
|
||||
@hideModal()
|
||||
|
||||
Reference in New Issue
Block a user