diff --git a/package-lock.json b/package-lock.json index a8582888..9c3d0d66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,7 +46,7 @@ "audit-ci": "^7.1.0", "eslint": "8.16.0", "eslint-config-standard": "17.1.0", - "eslint-plugin-jest": "28.8.0", + "eslint-plugin-jest": "28.8.1", "jest": "29.7.0", "jest-junit": "16.0.0", "npm-check-updates": "17.1.0", @@ -5277,9 +5277,9 @@ } }, "node_modules/eslint-plugin-jest": { - "version": "28.8.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.8.0.tgz", - "integrity": "sha512-Tubj1hooFxCl52G4qQu0edzV/+EZzPUeN8p2NnW5uu4fbDs+Yo7+qDVDc4/oG3FbCqEBmu/OC3LSsyiU22oghw==", + "version": "28.8.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.8.1.tgz", + "integrity": "sha512-G46XMyYu6PtSNJUkQ0hsPjzXYpzq/O4vpCciMizTKRJG8kNsRreGoMRDG6H9FIB/xVgfFuclVnuX4XRvFUzrZQ==", "dev": true, "dependencies": { "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0" @@ -9462,9 +9462,9 @@ } }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "dependencies": { "braces": "^3.0.3", diff --git a/package.json b/package.json index 01ebbc04..a2548335 100644 --- a/package.json +++ b/package.json @@ -138,7 +138,7 @@ "audit-ci": "^7.1.0", "eslint": "8.16.0", "eslint-config-standard": "17.1.0", - "eslint-plugin-jest": "28.8.0", + "eslint-plugin-jest": "28.8.1", "jest": "29.7.0", "jest-junit": "16.0.0", "npm-check-updates": "17.1.0", diff --git a/src/model/fxQuotes.js b/src/model/fxQuotes.js index 47d1c196..164a0df5 100644 --- a/src/model/fxQuotes.js +++ b/src/model/fxQuotes.js @@ -231,7 +231,7 @@ class FxQuotesModel { histTimer({ success: false, queryName: 'handleFxQuoteRequest' }) this.log.error('error in handleFxQuoteRequest', err) if (txn) { - txn.rollback(err) + await txn.rollback().catch(() => {}) } await this.handleException(fspiopSource, fxQuoteRequest.conversionRequestId, err, headers, childSpan) } finally { @@ -380,7 +380,7 @@ class FxQuotesModel { this.log.error('error in handleFxQuoteUpdate', err) const fspiopSource = headers[ENUM.Http.Headers.FSPIOP.SOURCE] if (txn) { - txn.rollback(err) + await txn.rollback().catch(() => {}) } await this.handleException(fspiopSource, conversionRequestId, err, headers, childSpan) } finally { @@ -534,7 +534,7 @@ class FxQuotesModel { }) // commit the txn to the db - txn.commit() + await txn.commit() } await childSpan.audit({ headers, params: { conversionRequestId } }, EventSdk.AuditEventAction.start) @@ -545,7 +545,7 @@ class FxQuotesModel { histTimer({ success: false, queryName: 'handleFxQuoteError' }) this.log.error('error in handleFxQuoteError', err) if (txn) { - txn.rollback(err) + await txn.rollback().catch(() => {}) } await this.handleException(fspiopSource, conversionRequestId, err, headers, childSpan) } finally { diff --git a/src/model/quotes.js b/src/model/quotes.js index 447764fd..7c90d4dc 100644 --- a/src/model/quotes.js +++ b/src/model/quotes.js @@ -417,7 +417,7 @@ class QuotesModel { } catch (err) { log.error('error in handleQuoteRequest:', err) if (txn) { - txn.rollback(err) + await txn.rollback().catch(() => {}) } const fspiopError = ErrorHandler.ReformatFSPIOPError(err) @@ -711,7 +711,7 @@ class QuotesModel { // internal-error this.writeLog(`Error in handleQuoteUpdate: ${getStackOrInspect(err)}`) if (txn) { - txn.rollback(err) + await txn.rollback().catch(() => {}) } const fspiopError = ErrorHandler.ReformatFSPIOPError(err) const state = new EventSdk.EventStateMetadata(EventSdk.EventStatusType.failed, fspiopError.apiErrorCode.code, fspiopError.apiErrorCode.message) @@ -857,7 +857,7 @@ class QuotesModel { }) // commit the txn to the db - txn.commit() + await txn.commit() } // create a new object to represent the error const fspiopError = ErrorHandler.CreateFSPIOPErrorFromErrorInformation(error) @@ -871,7 +871,7 @@ class QuotesModel { // internal-error this.writeLog(`Error in handleQuoteError: ${getStackOrInspect(err)}`) if (txn) { - txn.rollback(err) + await txn.rollback().catch(() => {}) } const fspiopError = ErrorHandler.ReformatFSPIOPError(err) const state = new EventSdk.EventStateMetadata(EventSdk.EventStatusType.failed, fspiopError.apiErrorCode.code, fspiopError.apiErrorCode.message) @@ -998,9 +998,10 @@ class QuotesModel { const childSpan = span.getChild('qs_quote_sendErrorCallback') try { await childSpan.audit({ headers, params: { quoteId } }, EventSdk.AuditEventAction.start) - await this.sendErrorCallback(fspiopSource, fspiopError, quoteId, headers, childSpan, true) + const result = await this.sendErrorCallback(fspiopSource, fspiopError, quoteId, headers, childSpan, true) histTimer({ success: true, queryName: 'quote_handleException' }) log.info('handleException is done') + return result } catch (err) { // any-error // not much we can do other than log the error diff --git a/test/unit/mocks.js b/test/unit/mocks.js index 2c4651eb..7c97da1c 100644 --- a/test/unit/mocks.js +++ b/test/unit/mocks.js @@ -118,7 +118,7 @@ const fxQuoteMocks = { }), db: ({ commit = jest.fn().mockResolvedValue({}), - rollback = jest.fn(), + rollback = jest.fn(() => Promise.reject(new Error('DB error'))), getParticipant = jest.fn().mockResolvedValue({}), getParticipantEndpoint = jest.fn().mockResolvedValue(undefined), createFxQuoteResponse = jest.fn().mockResolvedValue({}), diff --git a/test/unit/model/quotes.test.js b/test/unit/model/quotes.test.js index 43fda723..7ae814a8 100644 --- a/test/unit/model/quotes.test.js +++ b/test/unit/model/quotes.test.js @@ -124,7 +124,7 @@ describe('QuotesModel', () => { }) mockTransaction = { commit: jest.fn(), - rollback: jest.fn() + rollback: jest.fn(() => Promise.reject(new Error('DB error'))) } mockChildSpan = { injectContextToHttpRequest: jest.fn(opts => opts),