mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #20979 from overleaf/jpa-handle-error
[project-history] gracefully handle errors when loading Changes GitOrigin-RevId: 214fadb3c779551ea90f38b0fdf77c58ed5df178
This commit is contained in:
@@ -408,12 +408,20 @@ export function _processUpdates(
|
||||
)
|
||||
},
|
||||
(updatesWithBlobs, cb) => {
|
||||
const changes = UpdateTranslator.convertToChanges(
|
||||
projectId,
|
||||
updatesWithBlobs
|
||||
).map(change => change.toRaw())
|
||||
profile.log('convertToChanges')
|
||||
|
||||
let changes
|
||||
try {
|
||||
changes = UpdateTranslator.convertToChanges(
|
||||
projectId,
|
||||
updatesWithBlobs
|
||||
).map(change => change.toRaw())
|
||||
} catch (err) {
|
||||
return cb(err)
|
||||
} finally {
|
||||
profile.log('convertToChanges')
|
||||
}
|
||||
cb(null, changes)
|
||||
},
|
||||
(changes, cb) => {
|
||||
let change
|
||||
const numChanges = changes.length
|
||||
const byteLength = Buffer.byteLength(
|
||||
|
||||
@@ -390,6 +390,29 @@ describe('UpdatesProcessor', function () {
|
||||
return this.callback.should.have.been.called
|
||||
})
|
||||
})
|
||||
|
||||
describe('with an error converting changes', function () {
|
||||
beforeEach(function (done) {
|
||||
this.err = new Error()
|
||||
this.UpdateTranslator.convertToChanges.throws(this.err)
|
||||
this.callback = sinon.stub()
|
||||
|
||||
this.UpdatesProcessor._processUpdates(
|
||||
this.project_id,
|
||||
this.ol_project_id,
|
||||
this.rawUpdates,
|
||||
this.extendLock,
|
||||
err => {
|
||||
this.callback(err)
|
||||
done()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('should call the callback with the error', function () {
|
||||
this.callback.should.have.been.calledWith(this.err)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return describe('_skipAlreadyAppliedUpdates', function () {
|
||||
|
||||
Reference in New Issue
Block a user