feat: add timeout handler on FE (#3537)
* ✨ (frontend): Add TimeoutErrorComponent to handle timeout errors in API requests 🔧 (frontend): Add healthCheckTimeout state and setHealthCheckTimeout function to utilityStore for managing timeout errors in API requests * 📝 (constants.ts): add constants for server health check intervals to improve code readability and maintainability 🐛 (use-get-health.ts): fix refetch interval value to use the newly added constant REFETCH_SERVER_HEALTH_INTERVAL for consistency and easier maintenance * 📝 (api.tsx): Add utilityStore import to improve code organization 📝 (api.tsx): Add createNewError503 function to handle custom 503 errors 📝 (api.tsx): Add AxiosError import for type checking 📝 (api.tsx): Refactor error handling logic for authentication errors 📝 (use-get-health.ts): Add createNewError503 import for custom 503 errors 📝 (use-get-health.ts): Add AxiosError import for type checking 📝 (use-get-health.ts): Refactor error handling logic for server busy status 📝 (index.tsx): Add AxiosError import for type checking 📝 (index.tsx): Add useEffect and useState imports for state management 📝 (index.tsx): Refactor error handling logic for server status and retries 📝 (utilityStore.ts): Add retriesApiRequest state and setRetriesApiRequest function 📝 (axios-error-503.ts): Create function to generate custom 503 error responses 📝 (index.ts): Add retriesApiRequest state and setRetriesApiRequest function to UtilityStoreType * 🔧 (utilityStore.ts): remove unused retriesApiRequest and setRetriesApiRequest functions to clean up code and improve maintainability 🔧 (index.ts): remove unused retriesApiRequest and setRetriesApiRequest types to keep type definitions consistent and up to date * ✨ (nginx.conf): add new health endpoint to proxy_pass requests to the backend server for health checks * ✨ (langflow): Add support for configuring the number of retries for the health check feature. This change introduces a new option `health_check_max_retries` that can be set via environment variable or command line argument to control the maximum number of retries for the health check process. * check if value is none
This commit is contained in:
parent
9bf72ab444
commit
a763f57af5
17 changed files with 229 additions and 29 deletions
|
|
@ -130,6 +130,11 @@ def run(
|
|||
help="Defines the debounce time for the auto save.",
|
||||
envvar="LANGFLOW_AUTO_SAVING_INTERVAL",
|
||||
),
|
||||
health_check_max_retries: bool = typer.Option(
|
||||
True,
|
||||
help="Defines the number of retries for the health check.",
|
||||
envvar="LANGFLOW_HEALTH_CHECK_MAX_RETRIES",
|
||||
),
|
||||
):
|
||||
"""
|
||||
Run Langflow.
|
||||
|
|
@ -149,6 +154,7 @@ def run(
|
|||
store=store,
|
||||
auto_saving=auto_saving,
|
||||
auto_saving_interval=auto_saving_interval,
|
||||
health_check_max_retries=health_check_max_retries,
|
||||
)
|
||||
# create path object if path is provided
|
||||
static_files_dir: Optional[Path] = Path(path) if path else None
|
||||
|
|
|
|||
|
|
@ -340,3 +340,4 @@ class ConfigResponse(BaseModel):
|
|||
frontend_timeout: int
|
||||
auto_saving: bool
|
||||
auto_saving_interval: int
|
||||
health_check_max_retries: int
|
||||
|
|
|
|||
|
|
@ -159,6 +159,8 @@ class Settings(BaseSettings):
|
|||
"""If set to True, Langflow will auto save flows."""
|
||||
auto_saving_interval: int = 300
|
||||
"""The interval in ms at which Langflow will auto save flows."""
|
||||
health_check_max_retries: int = 5
|
||||
"""The maximum number of retries for the health check."""
|
||||
|
||||
@field_validator("dev")
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -430,6 +430,7 @@ def update_settings(
|
|||
store: bool = True,
|
||||
auto_saving: bool = True,
|
||||
auto_saving_interval: int = 300,
|
||||
health_check_max_retries: int = 5,
|
||||
):
|
||||
"""Update the settings from a config file."""
|
||||
from langflow.services.utils import initialize_settings_service
|
||||
|
|
@ -456,9 +457,12 @@ def update_settings(
|
|||
if not auto_saving:
|
||||
logger.debug("Setting auto_saving to False")
|
||||
settings_service.settings.update_settings(auto_saving=False)
|
||||
if auto_saving_interval:
|
||||
if auto_saving_interval is not None:
|
||||
logger.debug(f"Setting auto_saving_interval to {auto_saving_interval}")
|
||||
settings_service.settings.update_settings(auto_saving_interval=auto_saving_interval)
|
||||
if health_check_max_retries is not None:
|
||||
logger.debug(f"Setting health_check_max_retries to {health_check_max_retries}")
|
||||
settings_service.settings.update_settings(health_check_max_retries=health_check_max_retries)
|
||||
|
||||
|
||||
def is_class_method(func, cls):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue