-
-
Notifications
You must be signed in to change notification settings - Fork 544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(core): load items error #2342
Conversation
Either way, please don't PR the 4.x branch, the fix needs to go to master first (and if possible, we will cherry pick, otherwise do a separate/unrelated commit to 4.x). |
a01aab7
to
9757074
Compare
@B4nan done. Do you have any clues why this could be happening?
|
I guess its because of mixing the two approaches for transactions (em.begin vs em.transactional), will need to test it myself to be sure. |
You are right. If I wrap two |
The reason I need to make the |
So the problem here is that when you run I will respect the existing EM instance when merging the entities, but I not fully sure if we should backport this to v4, it feels somehow breaking (it does not break any existing tests tho, maybe I am just too cautious). |
@B4nan Does that mean on v5 this will work? Has this been fixed already on master? |
@B4nan maybe a way of avoiding breaking changes is having a parameter for default behaviors in cases like this. Although I'm not sure it is worth the effort and complexity doing this if you don't really care about supporting the old way. |
Yes, this is closed by a commit that fixed the issue (and yes, it is a oneliner). |
When running `em.transactional()`, all currently loaded entities are merged into the inner EM fork. But when that happens, their internal EM instance is updated to the fork, and it stays like that after you exit the transactional handler. So by calling the `loadItems()` (or any other method that works with the internal EM instance, e.g. `wrap(e).init()`), we would try to use the inner fork, that should no longer exists (and its transaction that is already finished). Closes #2342
For now this is just a failing test for an issue I found.
It happened to me while adding request level transactions to an Apollo application. Several resolvers started failing after running queries which contained nested transactions.
It looks like collections remain attached to the transaction that has already finished and
loadItems
fails.I tried calling
getContext()
in thegetEntityManager
method for theCollection
class but it didn't work. I'm not sure what's happening yet. Still working on it.I tested this both with
v4.5.9
andmaster
and it failed in both.@B4nan when we solve this, would it be possible to have a
v4.5.10
release?