File tree Expand file tree Collapse file tree
packages/ra-core/src/auth Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -111,9 +111,23 @@ const useLogout = (): Logout => {
111111 if ( redirectToParts [ 1 ] ) {
112112 newLocation . search = redirectToParts [ 1 ] ;
113113 }
114- navigateRef . current ( newLocation , newLocationOptions ) ;
115- resetStore ( ) ;
116- queryClient . clear ( ) ;
114+
115+ // We need to navigate and reset the store after a litte delay to avoid a race condition
116+ // between the store reset and the navigation.
117+ //
118+ // This would only happen when the `authProvider.getPermissions` method returns
119+ // a resolved promise with no delay: If the store was reset before the navigation,
120+ // the `usePermissions` query would reset, causing the `CoreAdminRoutes` component to
121+ // rerender the `LogoutOnMount` component leading to an infinite loop.
122+ setTimeout ( ( ) => {
123+ navigateRef . current (
124+ newLocation ,
125+ newLocationOptions
126+ ) ;
127+
128+ resetStore ( ) ;
129+ queryClient . clear ( ) ;
130+ } , 0 ) ;
117131
118132 return redirectToFromProvider ;
119133 } ) ;
You can’t perform that action at this time.
0 commit comments