Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

[members].map(() => makeGroupMembership(member)) would cause a Concurrent operation ConflictError #92

Open
xanderjakeq opened this issue Mar 10, 2020 · 1 comment

Comments

@xanderjakeq
Copy link

https://github.com/blockstack/radiks/blob/be57ef02595e5cbe44164550a86799dcb195f0cf/src/models/user-group.ts#L65

This might be caused by makeGroupMembership() saving the userGroup every time its called.

My solution for this is to sequentially call makeGroupMembership() with reduce.

[members].reduce(async (previous, member) => {
  const result = await previous;
  return [...result, await group.makeGroupMembership(member)];
}, Promise.resolve([]));

I think a better solution would be for makeGroupMembership() to take an array of usernames, iterate through them creating an Invitation for each, add them to the userGroup's members array, then save the userGroup with the updates.

@hstove
Copy link
Collaborator

hstove commented Apr 1, 2020

I think it would be cool to have a dedicated method for bulk invitation generation. I'm not sure if overloading the existing method is the right idea, but maybe. IMO, we should have a dedicated method for bulk invitations. Under the hood, it could be much more efficient in generating multiple invitations, and obviously fix this issue you're running into.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants