diff --git a/packages/react-router/tests/store-updates-during-navigation.test.tsx b/packages/react-router/tests/store-updates-during-navigation.test.tsx index 8768f65895..2b35683ef5 100644 --- a/packages/react-router/tests/store-updates-during-navigation.test.tsx +++ b/packages/react-router/tests/store-updates-during-navigation.test.tsx @@ -183,7 +183,7 @@ describe("Store doesn't update *too many* times during navigation", () => { // This number should be as small as possible to minimize the amount of work // that needs to be done during a navigation. // Any change that increases this number should be investigated. - expect(updates).toBe(8) + expect(updates).toBe(7) }) test('hover preload, then navigate, w/ async loaders', async () => { diff --git a/packages/router-core/src/router.ts b/packages/router-core/src/router.ts index 8321ed22c6..5b36456e94 100644 --- a/packages/router-core/src/router.ts +++ b/packages/router-core/src/router.ts @@ -2930,33 +2930,22 @@ export class RouterCore< } try { - await new Promise((resolveAll, rejectAll) => { - ;(async () => { - try { - // Execute all beforeLoads one by one - for (let i = 0; i < innerLoadContext.matches.length; i++) { - const beforeLoad = this.handleBeforeLoad(innerLoadContext, i) - if (isPromise(beforeLoad)) await beforeLoad - } - - // Execute all loaders in parallel - const max = - innerLoadContext.firstBadMatchIndex ?? - innerLoadContext.matches.length - for (let i = 0; i < max; i++) { - innerLoadContext.matchPromises.push( - this.loadRouteMatch(innerLoadContext, i), - ) - } + // Execute all beforeLoads one by one + for (let i = 0; i < innerLoadContext.matches.length; i++) { + const beforeLoad = this.handleBeforeLoad(innerLoadContext, i) + if (isPromise(beforeLoad)) await beforeLoad + } - await Promise.all(innerLoadContext.matchPromises) + // Execute all loaders in parallel + const max = + innerLoadContext.firstBadMatchIndex ?? innerLoadContext.matches.length + for (let i = 0; i < max; i++) { + innerLoadContext.matchPromises.push( + this.loadRouteMatch(innerLoadContext, i), + ) + } + await Promise.all(innerLoadContext.matchPromises) - resolveAll() - } catch (err) { - rejectAll(err) - } - })() - }) const readyPromise = this.triggerOnReady(innerLoadContext) if (isPromise(readyPromise)) await readyPromise } catch (err) {