-
-
Notifications
You must be signed in to change notification settings - Fork 23.5k
fix: add Redis connection resilience settings to prevent infinite hangs #5219
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
Open
utsav-bx
wants to merge
4
commits into
FlowiseAI:main
Choose a base branch
from
utsav-bx:bugfix/redis-connection-timeout-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix: add Redis connection resilience settings to prevent infinite hangs #5219
utsav-bx
wants to merge
4
commits into
FlowiseAI:main
from
utsav-bx:bugfix/redis-connection-timeout-fix
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HenryHengZJ
reviewed
Sep 28, 2025
HenryHengZJ
reviewed
Oct 1, 2025
utsav-bx
pushed a commit
to utsav-bx/Flowise
that referenced
this pull request
Nov 15, 2025
Addresses PR FlowiseAI#5219 feedback to add Redis connection resilience settings: - connectTimeout: Configurable via REDIS_CONNECT_TIMEOUT - commandTimeout: Configurable via REDIS_COMMAND_TIMEOUT - maxRetriesPerRequest: Configurable via REDIS_MAX_RETRIES_PER_REQUEST - lazyConnect: Configurable via REDIS_LAZY_CONNECT Settings are only included when explicitly set via environment variables, allowing Redis to use its own internal defaults when not configured. Also refactored keepAlive to use the same conditional spreading pattern.
utsav-bx
pushed a commit
to utsav-bx/Flowise
that referenced
this pull request
Nov 15, 2025
Addresses PR FlowiseAI#5219 feedback to add Redis connection resilience settings: - connectTimeout: Configurable via REDIS_CONNECT_TIMEOUT - commandTimeout: Configurable via REDIS_COMMAND_TIMEOUT - maxRetriesPerRequest: Configurable via REDIS_MAX_RETRIES_PER_REQUEST - lazyConnect: Configurable via REDIS_LAZY_CONNECT Settings are only included when explicitly set via environment variables, allowing Redis to use its own internal defaults when not configured. Also refactored keepAlive to use the same conditional spreading pattern.
- Add Redis timeout and retry configuration via environment variables - Fix waitUntilFinished() hanging indefinitely on Redis connection drops - Add connectTimeout, commandTimeout, maxRetriesPerRequest settings - Maintain backward compatibility with existing Redis env vars - Resolves issue FlowiseAI#5126 Breaking change: None
Addresses PR FlowiseAI#5219 feedback to add Redis connection resilience settings: - connectTimeout: Configurable via REDIS_CONNECT_TIMEOUT - commandTimeout: Configurable via REDIS_COMMAND_TIMEOUT - maxRetriesPerRequest: Configurable via REDIS_MAX_RETRIES_PER_REQUEST - lazyConnect: Configurable via REDIS_LAZY_CONNECT Settings are only included when explicitly set via environment variables, allowing Redis to use its own internal defaults when not configured. Also refactored keepAlive to use the same conditional spreading pattern.
Completes fix for issue FlowiseAI#5126 by adding explicit timeout parameters to all waitUntilFinished() calls across the codebase. Changes: - Added JOB_TIMEOUT environment variable (default: 300000ms / 5 minutes) - Applied timeout to waitUntilFinished in: - buildChatflow.ts (prediction queue) - agentflowv2-generator/index.ts (prediction queue) - upsertVector.ts (upsert queue) - nodes/index.ts (prediction queue - custom functions) - documentstore/index.ts (5 locations - upsert queue) - Updated .env.example with documentation for JOB_TIMEOUT and Redis resilience settings This prevents indefinite blocking when Redis fails or jobs hang, addressing the root cause where requests would return 504 timeouts with no automatic recovery.
a33cf59 to
761a13a
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #5126 - Flowise hangs indefinitely when Redis connections drop, causing
ECONNRESETerrors during queue processing.Solution
This PR implements a two-part fix to prevent indefinite hangs:
1. Redis Connection Resilience (Optional Configuration)
Adds configurable Redis connection settings via environment variables without hardcoded defaults:
REDIS_CONNECT_TIMEOUT- Connection timeout in millisecondsREDIS_COMMAND_TIMEOUT- Command timeout in millisecondsREDIS_MAX_RETRIES_PER_REQUEST- Maximum number of retries per requestREDIS_LAZY_CONNECT- Enable lazy connection (true/false)These settings are only applied if explicitly set, allowing Redis to use its own defaults otherwise.
2. Job Execution Timeouts (Core Fix)
Adds
JOB_TIMEOUTenvironment variable (default: 300000ms / 5 minutes) and implements explicit timeouts on alljob.waitUntilFinished()calls across:buildChatflow.tsagentflowv2-generator/index.tsdocumentstore/index.ts(5 occurrences)nodes/index.tsupsertVector.tsThis prevents jobs from hanging indefinitely when Redis connections fail.
Key Changes
packages/server/src/queue/QueueManager.tswith conditional Redis resilience settingspackages/server/.env.examplewith new configuration optionswaitUntilFinished()callsAddresses PR Feedback
Testing
pnpm build