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

not getting response from API for first query #1330

Closed
sampratha28 opened this issue Jan 14, 2024 · 4 comments
Closed

not getting response from API for first query #1330

sampratha28 opened this issue Jan 14, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@sampratha28
Copy link

When i hit the API predict endpoint, i am able to see the response in terminal, but the response in API is still buffering.
But when i send request to the API again, i am able to get response

Copy link

dosubot bot commented Jan 14, 2024

🤖

Hello @sampratha28! 👋

I'm Dosu, a friendly bot here to assist you while we wait for a human maintainer. I'm designed to help with bug solving, answering questions, and guiding contributors. Feel free to ask me anything you'd like about the project. Let's get your issue sorted out together. 😊

Based on the context provided, it seems like the issue you're experiencing might be related to the way the Axios interceptor is set up in the Langflow codebase. When a request is made and the server responds with a 401 status (unauthorized), the interceptor tries to renew the access token and then re-sends the original request with the new token. This process can take some time, which is why you're seeing the first request keep buffering. The second request is successful because by that time, the token has been renewed.

Here's the relevant part of the code:

if (error.response?.status === 401) {
  const refreshToken = cookies.get("refresh_tkn_lflw");
  if (refreshToken && refreshToken !== "auto") {
    authenticationErrorCount = authenticationErrorCount + 1;
    if (authenticationErrorCount > 3) {
      authenticationErrorCount = 0;
      logout();
      navigate("/login");
    }
    try {
      const res = await renewAccessToken(refreshToken);
      if (res?.data?.access_token && res?.data?.refresh_token) {
        login(res?.data?.access_token, res?.data?.refresh_token);
      }
      if (error?.config?.headers) {
        delete error.config.headers["Authorization"];
        error.config.headers["Authorization"] = `Bearer ${cookies.get(
          "access_tkn_lflw"
        )}`;
        const response = await axios.request(error.config);
        return response;
      }
    } catch (error) {
      if (axios.isAxiosError(error) && error.response?.status === 401) {
        logout();
        navigate("/login");
      } else {
        console.error(error);
        logout();
        navigate("/login");
      }
    }
  }
  ...
}

You can find this code in the api.tsx file.

If you're still having issues, could you provide more details about the request you're making and the response you're getting? This will help in diagnosing the problem.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added the bug Something isn't working label Jan 14, 2024
@sampratha28
Copy link
Author

@dosu-bot how can i resolve this issue so that the response is returned quickly for the first query itself

Copy link

dosubot bot commented Jan 14, 2024

🤖

Based on the information you've provided, it seems like the first request to the API is taking longer than expected, but subsequent requests are processed quickly. This could be due to a number of reasons, such as server cold starts, database connections, or other initialization processes that only occur on the first request.

If the issue is related to server cold starts, you might want to consider implementing a warm-up strategy. This could involve sending a dummy request to the API at regular intervals to keep the server warm. However, this would depend on the specific server and hosting environment you're using.

If the issue is related to database connections, you might want to check if connection pooling is enabled. Connection pooling can help reduce the time it takes to establish a new connection by reusing existing connections.

Without more specific information about your setup and the exact endpoint you're hitting, it's difficult to provide a more precise solution. Could you provide more details about the specific endpoint you're hitting and any error messages or logs you're seeing? This would help in diagnosing the issue.

For reference, here are the relevant files in the langflow repository:

Please review these files and let me know if you have any questions.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@anovazzi1
Copy link
Contributor

hey, did it work? if not can you export the flow for debugging?

@dosubot dosubot bot added the stale label Jun 20, 2024
@dosubot dosubot bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2024
@dosubot dosubot bot removed the stale label Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants