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
BaseEntity.reload returned promise doesn't wait for all queries #3681
Comments
Lazy-Loading with Promises was abandonded in the end of 2018. There sadly will be no further support and i also do have mny problems with Lazy-Loading, which seem to be never solved. |
Hm, from my reading of that comment, @pleerock said he was considering dropping it. But the website still lists it as a feature, albeit an experimental. @pleerock have you made a final choice on lazy relations yet? If so, and assuming the decision is to drop support, would you be willing to accept a PR that removes them from the website, or at least makes it clear that it's not supported (vs. experimental). |
The thing is, that the PR from my link would fix some very important thing for lazy loading. But from the comment from las year i assume it never gets merged. If Promises would be supported, they should merge the PRs that are important for them to work and not putting them on hold. |
Lazy loading will be reinvented in 0.4.0. Current behavior isn't working very well(e.g. when setting value you have to pack it in a promise) and it's error prone. As for referenced PR - I'm not sure if it will be merged. I think it's more about priorities. Unfortunately we don't have as much time as we would like so we have to prioritize. Deciding either to merge or not this PR takes time and PRs 'with laziness' were troublesome in the past. It's easy to break other functionalities by them so it have to be revived carefully(which takes more time then reviving some other PRs). |
I'm having the same issue with lazy relations and using reload. Is there any timeline when to expect the fix or 0.4.0? |
+1 having this issue, it caused flakiness in our tests. Any chances to have a fix for it anytime soon? |
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[x]
N/A
[ ]
cordova
[ ]
mongodb
[ ]
mssql
[ ]
mysql
/mariadb
[ ]
oracle
[ ]
postgres
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
[ ]
expo
TypeORM version:
[x]
latest
[ ]
@next
[x]
0.2.12
Steps to reproduce or a small repository showing the problem:
The
BaseEntity.reload()
method fetches the entity from the database and does a mass assignment from the newly fetched entity onto the existing entity that is being reloaded:This mass assignment triggers any lazy relationships for this entity to load since lazy relationships are represented as getters. That results in (potentially) a series of queries hitting the database.
However, the promise returned by
reload()
doesn't track any of these. The result is that queries hit the database afterawait entity.reload()
finishes.This is somewhat surprising, and also makes certain scenarios difficult. For example, tests that hit
.reload()
and also teardown the database connection on completion will start throwingConnection terminated
errors, because the test can't wait for those queries that.reload()
triggers to finish before disconnecting).I'm not sure the best path forward to fix this. Whether or not those lazy relationships should be reloaded isn't obvious to me. If we are okay not reloading them, then we could filter the mass assignment down to exclude lazy-loaded relationships. Or, if we do want to reload those lazy relationships as well, then we could filter out those relationships so we can capture their promises.
The text was updated successfully, but these errors were encountered: