@@ -808,27 +808,33 @@ const InnerRouter = ({ initialRoute }: { initialRoute: RouteProps }) => {
808
808
executeListeners ( 'start' , route ) ;
809
809
refetching . current = [ ] ;
810
810
setErr ( null ) ;
811
- if ( ! staticPathSetRef . current . has ( route . path ) && ! skipRefetch ) {
812
- const rscPath = encodeRoutePath ( route . path ) ;
813
- const rscParams = createRscParams ( route . query ) ;
814
- try {
815
- await refetch ( rscPath , rscParams ) ;
816
- } catch ( e ) {
817
- refetching . current = null ;
818
- setErr ( e ) ;
819
- throw e ;
811
+ try {
812
+ if ( ! staticPathSetRef . current . has ( route . path ) && ! skipRefetch ) {
813
+ const rscPath = encodeRoutePath ( route . path ) ;
814
+ const rscParams = createRscParams ( route . query ) ;
815
+ try {
816
+ await refetch ( rscPath , rscParams ) ;
817
+ } catch ( e ) {
818
+ refetching . current = null ;
819
+ setErr ( e ) ;
820
+ throw e ;
821
+ }
820
822
}
823
+ } finally {
824
+ if ( shouldScroll ) {
825
+ handleScroll ( ) ;
826
+ }
827
+ if ( options . history ) {
828
+ handleHistory ( options . history , {
829
+ requestedRoute : route ,
830
+ initialRoute,
831
+ } ) ;
832
+ }
833
+ setRoute ( route ) ;
834
+ refetching . current ! [ 0 ] ?.( ) ;
835
+ refetching . current = null ;
836
+ executeListeners ( 'complete' , route ) ;
821
837
}
822
- if ( shouldScroll ) {
823
- handleScroll ( ) ;
824
- }
825
- if ( options . history ) {
826
- handleHistory ( options . history , { requestedRoute : route , initialRoute } ) ;
827
- }
828
- setRoute ( route ) ;
829
- refetching . current ! [ 0 ] ?.( ) ;
830
- refetching . current = null ;
831
- executeListeners ( 'complete' , route ) ;
832
838
} ,
833
839
[ executeListeners , refetch ] ,
834
840
) ;
0 commit comments