mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
[DocumentUpdaterManager] use a new NullBytesInOpError
This commit is contained in:
parent
af50f9b02c
commit
6828becb46
2 changed files with 14 additions and 8 deletions
|
@ -6,7 +6,7 @@ const _ = require('underscore')
|
|||
const logger = require('logger-sharelatex')
|
||||
const settings = require('settings-sharelatex')
|
||||
const metrics = require('metrics-sharelatex')
|
||||
const { UpdateTooLargeError } = require('./Errors')
|
||||
const { NullBytesInOpError, UpdateTooLargeError } = require('./Errors')
|
||||
|
||||
const rclient = require('redis-sharelatex').createClient(
|
||||
settings.redis.documentupdater
|
||||
|
@ -116,12 +116,7 @@ const DocumentUpdaterManager = {
|
|||
const jsonChange = JSON.stringify(change)
|
||||
if (jsonChange.indexOf('\u0000') !== -1) {
|
||||
// memory corruption check
|
||||
const error = new Error('null bytes found in op')
|
||||
logger.error(
|
||||
{ err: error, project_id, doc_id, jsonChange },
|
||||
error.message
|
||||
)
|
||||
return callback(error)
|
||||
return callback(new NullBytesInOpError(jsonChange))
|
||||
}
|
||||
|
||||
const updateSize = jsonChange.length
|
||||
|
|
|
@ -15,10 +15,21 @@ class DataTooLargeToParseError extends OError {
|
|||
}
|
||||
}
|
||||
|
||||
class NullBytesInOpError extends OError {
|
||||
constructor(jsonChange) {
|
||||
super('null bytes found in op', { jsonChange })
|
||||
}
|
||||
}
|
||||
|
||||
class UpdateTooLargeError extends OError {
|
||||
constructor(updateSize) {
|
||||
super('update is too large', { updateSize })
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { CodedError, DataTooLargeToParseError, UpdateTooLargeError }
|
||||
module.exports = {
|
||||
CodedError,
|
||||
DataTooLargeToParseError,
|
||||
NullBytesInOpError,
|
||||
UpdateTooLargeError
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue