I noticed some conflicts when retrieving loggedinuser infos in typeorm event.
I have registered the loggedinuser in a middleware
req.scope.register({ loggedInUser: { resolve: () => loggedInUser, }, });
and then I listen to beforeInsert event for products to add the store_id to the object
`@OnMedusaEntityEvent.Before.Insert(Product, { async: true })
public async beforeProductInsert(
params: MedusaEventHandlerParams<Product, "Insert">
): Promise<EntityEventType<Product, "Insert">> {
const { event } = params;
const loggedInUser = this.container.loggedInUser;
event.entity.store_id = loggedInUser.store_id;`
This is working most of the time but in 1% of the cases the wrong store_id is affected to the product. This is occuring especially if we do concurrent product creations by two different logged-in users.
@bold kernel did you already get this error ? Do you have a solution ?