From 16f38e2718a6cccaed517a10cdc867c1e2e1d05c Mon Sep 17 00:00:00 2001 From: Xen0Xys Date: Wed, 7 Feb 2024 17:50:27 +0100 Subject: [PATCH] :bug: Increase prisma transaction timeout for secret rotation --- src/modules/security/secrets/secrets.service.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/modules/security/secrets/secrets.service.ts b/src/modules/security/secrets/secrets.service.ts index b76f470..040039b 100644 --- a/src/modules/security/secrets/secrets.service.ts +++ b/src/modules/security/secrets/secrets.service.ts @@ -30,10 +30,15 @@ export class SecretsService{ const start = Date.now(); const users: UserEntity[] = await this.usersService.findAll(); const promises = []; - for(const user of users) - promises.push(this.rotateUserSecret(user)); - await Promise.all(promises); - this.logger.log(`Rotated ${users.length} users in ${Date.now() - start}ms`); + try{ + for(const user of users) + promises.push(this.rotateUserSecret(user)); + await Promise.all(promises); + this.logger.log(`Rotated ${users.length} users in ${Date.now() - start}ms`); + }catch(e){ + this.logger.log("Error when rotating secrets"); + console.log(e); + } AdminController.isMaintenanceMode = maintenanceModeState; AdminController.maintenanceMessage = maintenanceModeMessage; } @@ -48,7 +53,7 @@ export class SecretsService{ promises.push(this.todosService.rotateTasksCipher(tx, user, secret, newSecret)); await Promise.all(promises); await this.usersService.setUserSecret(tx, user, newSecret); - }); + }, {timeout: 10000}); const stop = Date.now(); this.logger.log(`Rotated user ${user.id} in ${stop - start}ms`); }