You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Somewhat related to #2380 as I don't think this would be a problem in most write requests/scenarios. I am noticing some strange behavior when entities with the same id are being populated with different values across two different Promises. At times Collections just simply disappear or a Refs has been nulled out when accessed later. I suspect this may due to cascades happening across Promises at the same time. It is hard to create a reproduction for as it isn't consistent due to latency differences/IO. It is more prevalent in serverless frameworks which execute nested routes in parallel.
As a workaround, when I am in a read-only request, I simply set disableIdentityMap to true (I wrap EntityManager with my own implementation) so that there are no collisions but this comes at a potential performance cost (I assume) as it can't shared pre-fetched entities across Promises.
Digging through the code a bit, I think my suggestion would be to update the EntityFactory.create and introduce a queue here:
Somewhat related to #2380 as I don't think this would be a problem in most write requests/scenarios. I am noticing some strange behavior when entities with the same id are being populated with different values across two different
Promise
s. At timesCollection
s just simply disappear or aRef
s has been nulled out when accessed later. I suspect this may due to cascades happening acrossPromise
s at the same time. It is hard to create a reproduction for as it isn't consistent due to latency differences/IO. It is more prevalent in serverless frameworks which execute nested routes in parallel.As a workaround, when I am in a read-only request, I simply set
disableIdentityMap
to true (I wrap EntityManager with my own implementation) so that there are no collisions but this comes at a potential performance cost (I assume) as it can't shared pre-fetched entities acrossPromise
s.Digging through the code a bit, I think my suggestion would be to update the
EntityFactory.create
and introduce a queue here:mikro-orm/packages/core/src/entity/EntityFactory.ts
Lines 55 to 94 in ff00110
Every find is added to a queue with a callback
fn(existing:Entity) => Entity
which would prevent merges/cascades happening out of order.The text was updated successfully, but these errors were encountered: