[document-updater] add missing await (#31034)

Co-authored-by: Brian Gough <brian.gough@overleaf.com>
GitOrigin-RevId: f0602801ce80ca617027004ad36f71c1e6cdcdd2
This commit is contained in:
Jakob Ackermann
2026-01-26 17:29:26 +00:00
committed by Copybot
parent d5936d8566
commit 86b29819c2
2 changed files with 32 additions and 7 deletions

View File

@@ -96,13 +96,21 @@ async function resyncProjectHistory(
if (opts.resyncProjectStructureOnly) return
const DocumentManager = require('./DocumentManager')
await promiseMapWithLimit(MAX_PARALLEL_REQUESTS, docs, doc => {
DocumentManager.promises.resyncDocContentsWithLock(
projectId,
doc.doc,
doc.path,
opts
)
await promiseMapWithLimit(MAX_PARALLEL_REQUESTS, docs, async doc => {
const { doc: docId, path } = doc
try {
await DocumentManager.promises.resyncDocContentsWithLock(
projectId,
docId,
path,
opts
)
} catch (err) {
throw OError.tag(err, 'resyncDocContents', {
projectId,
docId,
})
}
})
}

View File

@@ -1,6 +1,7 @@
/* eslint-disable
mocha/no-nested-tests,
*/
const { expect } = require('chai')
const SandboxedModule = require('sandboxed-module')
const sinon = require('sinon')
const modulePath = require('node:path').join(
@@ -206,6 +207,22 @@ describe('HistoryManager', function () {
]
})
describe('error', function () {
it('should throw directly', async function () {
const err = new Error()
this.DocumentManager.promises.resyncDocContentsWithLock.rejects(err)
await expect(
this.HistoryManager.promises.resyncProjectHistory(
this.project_id,
this.projectHistoryId,
this.docs,
this.files,
{}
)
).to.be.rejectedWith(err)
})
})
describe('full sync', function () {
beforeEach(async function () {
await this.HistoryManager.promises.resyncProjectHistory(