Skip to content

Commit

Permalink
🐛 Increase prisma transaction timeout for secret rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Xen0Xys committed Feb 7, 2024
1 parent abcddbe commit 16f38e2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/modules/security/secrets/secrets.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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`);
}
Expand Down

0 comments on commit 16f38e2

Please sign in to comment.