mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 13:47:33 +01:00
* fix #12124
add a transaction for updating user and group
so the user doesn't lose gems when saving the group fails
* use mongoose transaction helper
use the helper instead of manually commiting/aborting
to deal with transient transaction errors
* increase timeout and add console.log outputs
add some logging to a failing test
* Revert "increase timeout and add console.log outputs"
This reverts commit 0c36aaa55f.
* add a test for gems when guild creation fails
test the transaction in createGroup()
make sure user keeps the gems if group.save() rejects
* fix(test): try suggested delay from PR discussion
Co-authored-by: SabreCat <sabe@habitica.com>
This commit is contained in:
committed by
GitHub
parent
9a3e3c93eb
commit
1823f658c6
@@ -137,8 +137,12 @@ api.createGroup = {
|
||||
user.party._id = group._id;
|
||||
}
|
||||
|
||||
const results = await Promise.all([user.save(), group.save()]);
|
||||
const savedGroup = results[1];
|
||||
let savedGroup;
|
||||
|
||||
await Group.db.transaction(async session => {
|
||||
await user.save({ session });
|
||||
savedGroup = await group.save({ session });
|
||||
});
|
||||
|
||||
// Instead of populate we make a find call manually because of https://github.com/Automattic/mongoose/issues/3833
|
||||
// await Q.ninvoke(savedGroup, 'populate', ['leader', nameFields]);
|
||||
|
||||
Reference in New Issue
Block a user