diff --git a/services/document-updater/app/js/HistoryManager.js b/services/document-updater/app/js/HistoryManager.js index c473a5b2bd..30983b5b9d 100644 --- a/services/document-updater/app/js/HistoryManager.js +++ b/services/document-updater/app/js/HistoryManager.js @@ -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, + }) + } }) } diff --git a/services/document-updater/test/unit/js/HistoryManager/HistoryManagerTests.js b/services/document-updater/test/unit/js/HistoryManager/HistoryManagerTests.js index c53ffeb4fe..9e8c3bf9b0 100644 --- a/services/document-updater/test/unit/js/HistoryManager/HistoryManagerTests.js +++ b/services/document-updater/test/unit/js/HistoryManager/HistoryManagerTests.js @@ -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(