Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: server busy error even when the server is responding #4403

Merged
merged 3 commits into from
Nov 5, 2024
Merged
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
10 changes: 9 additions & 1 deletion src/frontend/src/controllers/API/api.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LANGFLOW_ACCESS_TOKEN } from "@/constants/constants";
import { useCustomApiHeaders } from "@/customization/hooks/use-custom-api-headers";
import useAuthStore from "@/stores/authStore";
import { useUtilityStore } from "@/stores/utilityStore";
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig } from "axios";
import * as fetchIntercept from "fetch-intercept";
import { useEffect } from "react";
Expand Down Expand Up @@ -33,6 +34,10 @@ function ApiInterceptor() {
const isLoginPage = location.pathname.includes("login");
const customHeaders = useCustomApiHeaders();

const setHealthCheckTimeout = useUtilityStore(
(state) => state.setHealthCheckTimeout,
);

useEffect(() => {
const unregister = fetchIntercept.register({
request: function (url, config) {
Expand All @@ -49,7 +54,10 @@ function ApiInterceptor() {
});

const interceptor = api.interceptors.response.use(
(response) => response,
(response) => {
setHealthCheckTimeout(null);
return response;
},
async (error: AxiosError) => {
const isAuthenticationError =
error?.response?.status === 403 || error?.response?.status === 401;
Expand Down
Loading