Skip to content

Commit 168f29f

Browse files
committed
Finally clause inside changeRoute
1 parent da59532 commit 168f29f

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

packages/waku/src/router/client.ts

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -808,27 +808,33 @@ const InnerRouter = ({ initialRoute }: { initialRoute: RouteProps }) => {
808808
executeListeners('start', route);
809809
refetching.current = [];
810810
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+
}
820822
}
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);
821837
}
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);
832838
},
833839
[executeListeners, refetch],
834840
);

0 commit comments

Comments
 (0)