Skip to content

Commit 9e572d0

Browse files
committed
Attempt to fix causal consistency on getAllOrgs
1 parent 9353b21 commit 9e572d0

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

src/controller/registry-org.controller/registry-org.controller.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@ const validateUUID = require('uuid').validate
2020
*/
2121
async function getAllOrgs (req, res, next) {
2222
try {
23-
const session = await mongoose.startSession({ causalConsistency: false })
2423
const repo = req.ctx.repositories.getBaseOrgRepository()
2524
const conversationRepo = req.ctx.repositories.getConversationRepository()
26-
const isSecretariat = await repo.isSecretariatByShortName(req.ctx.org, { session })
25+
const isSecretariat = await repo.isSecretariatByShortName(req.ctx.org)
2726
const CONSTANTS = getConstants()
2827
let returnValue
2928

@@ -38,26 +37,23 @@ async function getAllOrgs (req, res, next) {
3837
options.page = req.ctx.query.page ? parseInt(req.ctx.query.page) : CONSTANTS.PAGINATOR_PAGE // if 'page' query parameter is not defined, set 'page' to the default page value
3938

4039
try {
41-
returnValue = await repo.getAllOrgs({ ...options, session })
40+
returnValue = await repo.getAllOrgs({ ...options })
4241
// fetch conversations
4342
for (let i = 0; i < returnValue.organizations.length; i++) {
44-
const conversation = await conversationRepo.getAllByTargetUUID(returnValue.organizations[i].UUID, isSecretariat, { session })
43+
const conversation = await conversationRepo.getAllByTargetUUID(returnValue.organizations[i].UUID, isSecretariat)
4544
returnValue.organizations[i].conversation = conversation?.length ? conversation : undefined
4645
}
4746
} catch (error) {
4847
// Handle the specific error thrown by BaseOrgRepository.createOrg
4948
if (error.message && error.message.includes('Unknown Org type requested')) {
5049
return res.status(400).json({ message: error.message })
5150
}
52-
return res.status(500).json({ catch: 'inner', message: error })
53-
} finally {
54-
await session.endSession()
5551
}
5652

5753
logger.info({ uuid: req.ctx.uuid, message: 'The orgs were sent to the user.' })
5854
return res.status(200).json(returnValue)
5955
} catch (err) {
60-
return res.status(500).json({ catch: 'outer', message: err })
56+
next(err)
6157
}
6258
}
6359

0 commit comments

Comments
 (0)