mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Gracefully return when an op has already been submitted
It is not a fatal error if an op has already been submitted. We just need to send an ack back to the client that submitted it and continue. If we detect a duplicate op, set dup: true on the op and pass it back to real-time for distributing. The dup: true flag will ensure it only gets acknowledged to the submitting client, not everyone.
This commit is contained in:
parent
e73890bfc2
commit
2589e2d417
1 changed files with 17 additions and 6 deletions
|
@ -32,7 +32,14 @@ module.exports = ShareJsUpdateManager =
|
|||
for update in updates
|
||||
do (update) =>
|
||||
jobs.push (callback) =>
|
||||
model.applyOp doc_key, update, callback
|
||||
model.applyOp doc_key, update, (error) ->
|
||||
if error == "Op already submitted"
|
||||
logger.warn {project_id, doc_id, update}, "op has already been submitted"
|
||||
update.dup = true
|
||||
ShareJsUpdateManager._sendOp(project_id, doc_id, update)
|
||||
callback()
|
||||
else
|
||||
callback(error)
|
||||
|
||||
async.series jobs, (error) =>
|
||||
logger.log project_id: project_id, doc_id: doc_id, error: error, "applied updates"
|
||||
|
@ -49,11 +56,15 @@ module.exports = ShareJsUpdateManager =
|
|||
_listenForOps: (model) ->
|
||||
model.on "applyOp", (doc_key, opData) ->
|
||||
[project_id, doc_id] = Keys.splitProjectIdAndDocId(doc_key)
|
||||
data = JSON.stringify
|
||||
project_id: project_id
|
||||
doc_id: doc_id
|
||||
op: opData
|
||||
rclient.publish "applied-ops", data
|
||||
ShareJsUpdateManager._sendOp(project_id, doc_id, opData)
|
||||
|
||||
_sendOp: (project_id, doc_id, opData) ->
|
||||
data =
|
||||
project_id: project_id
|
||||
doc_id: doc_id
|
||||
op: opData
|
||||
data = JSON.stringify data
|
||||
rclient.publish "applied-ops", data
|
||||
|
||||
_sendError: (project_id, doc_id, error) ->
|
||||
data = JSON.stringify
|
||||
|
|
Loading…
Reference in a new issue