Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/pages/studio/hooks/useBatchSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
hasActionLoras,
} from "../constants/duration-options";

const BATCH_SIZE = 5;
// Serialized to avoid concurrent auth refresh races (see fix/session-refresh-race on backend)
const BATCH_SIZE = 1;

export const useBatchSubmit = () => {
const images = useStudioStore((s) => s.images);
Expand Down
15 changes: 10 additions & 5 deletions src/hooks/useHttpInterceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type ResponseGeneratorProps = {
logout: () => Promise<void>;
};

let isLoggingOut = false;

const generateResponseInterceptor = async ({
logout,
}: ResponseGeneratorProps) => {
Expand All @@ -38,14 +40,17 @@ const generateResponseInterceptor = async ({
(response) => response,
async (error) => {
if (error?.response?.status === 401) {
// Handle unauthorized error
queryClient.clear();
await logout();
router.navigate(ROUTES.SIGNIN);
if (!isLoggingOut) {
isLoggingOut = true;
queryClient.clear();
await logout();
router.navigate(ROUTES.SIGNIN);
isLoggingOut = false;
}
return Promise.reject(error);
}

return error.response;
return Promise.reject(error);
},
);
};
Expand Down
Loading