mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-25 17:10:51 +00:00
[ShareJsUpdateManager] double check doc size before flushing
This commit is contained in:
parent
06d1a12782
commit
a4ae0ea12f
1 changed files with 14 additions and 0 deletions
|
@ -87,6 +87,20 @@ module.exports = ShareJsUpdateManager = {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
|
const docSizeAfter = data.snapshot.length
|
||||||
|
if (docSizeAfter > Settings.max_doc_length) {
|
||||||
|
const docSizeBefore = lines.join('\n').length
|
||||||
|
const err = new Error(
|
||||||
|
'blocking persistence of ShareJs update: doc size exceeds limits'
|
||||||
|
)
|
||||||
|
logger.error(
|
||||||
|
{ project_id, doc_id, err, docSizeBefore, docSizeAfter },
|
||||||
|
err.message
|
||||||
|
)
|
||||||
|
metrics.inc('sharejs.other-error')
|
||||||
|
const publicError = 'Update takes doc over max doc size'
|
||||||
|
return callback(publicError)
|
||||||
|
}
|
||||||
// only check hash when present and no other updates have been applied
|
// only check hash when present and no other updates have been applied
|
||||||
if (update.hash != null && incomingUpdateVersion === version) {
|
if (update.hash != null && incomingUpdateVersion === version) {
|
||||||
const ourHash = ShareJsUpdateManager._computeHash(data.snapshot)
|
const ourHash = ShareJsUpdateManager._computeHash(data.snapshot)
|
||||||
|
|
Loading…
Reference in a new issue