fix: ensure reloading an allocation doesn't result in an infinite loop

`allocation.reload()` has differnt semantics for reloading, as it will
reload the record in the background and immediately resolve [1].

By using the stores' findRecord and specifying `backgroundReload:
false`, we make sure we await the response from the server and hereby
have the complete record once we continue in the code.

Using `allocation.reoad()` causes and infinite loop when we upgrade
ember-data to 3.16 (and model fragments to 5.0.0-beta.2).

[1] This is, unless `shouldBackgroundReload` on the adapter returns
false, but it's true by default.
This commit is contained in:
pangratz 2021-11-02 22:07:47 +01:00
parent 0978685e71
commit 0fdedc344b

View file

@ -86,7 +86,7 @@ async function qualifyAllocation() {
// Make sure the allocation is a complete record and not a partial so we
// can show information such as preemptions and rescheduled allocation.
if (allocation.isPartial) {
await allocation.reload();
await this.store.findRecord('allocation', allocation.id, { backgroundReload: false });
}
if (allocation.get('job.isPending')) {