FIX: Stick to then/finally in history-store (#30061)

async/await doesn't play well with transitions (to be investigated… later)
This commit is contained in:
Jarek Radosz 2024-12-03 14:13:26 +01:00 committed by GitHub
parent c3e87b5036
commit 48323230a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -111,7 +111,7 @@ export default class HistoryStore extends Service {
* not available as an event on the router service.
*/
@bind
async willResolveModel(transition) {
willResolveModel(transition) {
if (HANDLED_TRANSITIONS.has(transition)) {
return;
}
@ -141,16 +141,16 @@ export default class HistoryStore extends Service {
}
this.#pendingStore = pendingStoreForThisTransition;
try {
await transition;
this.#uuid = window.history.state?.uuid;
this.#routeData.set(this.#uuid, this.#pendingStore);
this.#pruneOldData();
} finally {
if (pendingStoreForThisTransition === this.#pendingStore) {
this.#pendingStore = null;
}
}
transition
.then(() => {
this.#uuid = window.history.state?.uuid;
this.#routeData.set(this.#uuid, this.#pendingStore);
this.#pruneOldData();
})
.finally(() => {
if (pendingStoreForThisTransition === this.#pendingStore) {
this.#pendingStore = null;
}
});
}
}