Skip to content

Commit 8843975

Browse files
committed
only load lazy routes on non redirect
1 parent 4ab6338 commit 8843975

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/router-core/src/load-matches.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,16 +467,21 @@ const executeBeforeLoad = (
467467
pending()
468468
return beforeLoadContext
469469
.catch(async (err) => {
470-
await loadRouteChunk(route)
470+
if (!isRedirect(err)) {
471+
await loadRouteChunk(route)
472+
}
471473
handleSerialError(inner, index, err, 'BEFORE_LOAD')
472474
})
473475
.then(updateContext)
474476
}
475477
} catch (err) {
476478
pending()
477-
return loadRouteChunk(route).then(() => {
478-
handleSerialError(inner, index, err, 'BEFORE_LOAD')
479-
})
479+
if (!isRedirect(err)) {
480+
return loadRouteChunk(route).then(() => {
481+
handleSerialError(inner, index, err, 'BEFORE_LOAD')
482+
})
483+
}
484+
return handleSerialError(inner, index, err, 'BEFORE_LOAD')
480485
}
481486

482487
updateContext(beforeLoadContext)

0 commit comments

Comments
 (0)