[PR #26685] feat: update HTTP timeout configurations and enhance timeout input handling in UI #31519

Closed
opened 2026-02-21 20:49:37 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/26685

State: closed
Merged: Yes


Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Fixes #26319

Increases HTTP request node timeout defaults and exposes configuration to allow users to configure longer timeouts for slow external services.

🔍 Problem

Users reported that the HTTP node times out after 10 minutes even when they need longer timeouts for slow-processing services (like document processing, knowledge base operations, video generation, etc.).

Root causes:

  1. Low default timeout limits - Backend defaults were set too conservatively:

    • Read timeout: 60s (1 minute)
    • Write timeout: 20s
    • These were insufficient for many real-world use cases
  2. Hard-coded frontend limits - Frontend enforced maximum values that couldn't be overridden:

    • Connect timeout: capped at 300s (5 minutes)
    • Read/Write timeout: capped at 600s (10 minutes)
  3. Missing configuration exposure - Even though backend supported custom limits via environment variables (HTTP_REQUEST_MAX_CONNECT_TIMEOUT, etc.), these were not documented or properly integrated with Docker deployment.

Solution

1. Increased Default Timeout Values

Updated backend defaults to more practical values for real-world scenarios:

Timeout Type Old Default New Default Reason
Connect 10s 10s (unchanged) Connection failures are typically fast to detect
Read 60s 600s (10 min) Allows slow API responses, large file downloads
Write 20s 600s (10 min) Allows large file uploads, slow request processing

2. Exposed Configuration to Docker Deployment

Added environment variables to .env.example and docker-compose.yaml:

# HTTP request node timeout configuration
# Maximum timeout values (in seconds) that users can set in HTTP request nodes
# - Connect timeout: Time to wait for establishing connection (default: 10s)
# - Read timeout: Time to wait for receiving response data (default: 600s, 10 minutes)
# - Write timeout: Time to wait for sending request data (default: 600s, 10 minutes)
HTTP_REQUEST_MAX_CONNECT_TIMEOUT=10
HTTP_REQUEST_MAX_READ_TIMEOUT=600
HTTP_REQUEST_MAX_WRITE_TIMEOUT=600

Self-hosted users can now easily customize these values by setting environment variables.

3. Enhanced Frontend to Respect Backend Configuration

Updated the frontend timeout component to:

  • Dynamically read maximum timeout values from backend configuration
  • Use proper fallback chain: payload.max_X_timeoutbackend_config.max_X_timeouthardcoded_default
  • Respect backend as the source of truth for timeout limits
  • Maintain minimum validation (1 second) to prevent invalid inputs

4. Improved Test Coverage

  • Added test_http_timeout_defaults() to verify new default values
  • Updated existing tests to use custom values for clarity
  • All 13 config tests passing

📊 Changes

Files Modified: 5 files, +51 insertions, -13 deletions

  • __init__.py - Updated default timeout values
  • .env.example - Added timeout configuration with documentation
  • docker-compose.yaml - Added environment variable mappings
  • index.tsx - Enhanced to read backend config
  • test_dify_config.py - Added test coverage for new defaults

🧪 Testing

All tests passing:

✅ test_dify_config - Validates custom configuration
✅ test_http_timeout_defaults - Validates new default values
✅ test_flask_configs - Validates Flask integration
✅ test_inner_api_config_exist - Validates inner API config
✅ ... (13 tests total, all passed)

Manual testing scenarios:

  • HTTP node with default timeouts works correctly
  • Custom timeout values via environment variables are respected
  • Frontend displays correct maximum values from backend
  • Validation prevents values < 1 second
  • Users can configure timeouts beyond previous hard limits

🎯 Benefits

  1. Better defaults - 10-minute timeouts are more suitable for real-world API integrations
  2. Full configurability - Self-hosted users can customize via environment variables
  3. Clear documentation - Configuration options are now documented in .env.example
  4. Proper separation of concerns - Backend controls security boundaries, frontend provides UX
  5. Backward compatible - Existing workflows continue to work without changes

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/26685 **State:** closed **Merged:** Yes --- > [!IMPORTANT] > > 1. Make sure you have read our [contribution guidelines](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) > 1. Ensure there is an associated issue and you have been assigned to it > 1. Use the correct syntax to link this PR: `Fixes #<issue number>`. ### Summary Fixes #26319 Increases HTTP request node timeout defaults and exposes configuration to allow users to configure longer timeouts for slow external services. ### 🔍 Problem Users reported that the HTTP node times out after 10 minutes even when they need longer timeouts for slow-processing services (like document processing, knowledge base operations, video generation, etc.). **Root causes:** 1. **Low default timeout limits** - Backend defaults were set too conservatively: - Read timeout: 60s (1 minute) - Write timeout: 20s - These were insufficient for many real-world use cases 2. **Hard-coded frontend limits** - Frontend enforced maximum values that couldn't be overridden: - Connect timeout: capped at 300s (5 minutes) - Read/Write timeout: capped at 600s (10 minutes) 3. **Missing configuration exposure** - Even though backend supported custom limits via environment variables (`HTTP_REQUEST_MAX_CONNECT_TIMEOUT`, etc.), these were not documented or properly integrated with Docker deployment. ### ✅ Solution #### 1. **Increased Default Timeout Values** Updated backend defaults to more practical values for real-world scenarios: | Timeout Type | Old Default | New Default | Reason | |-------------|-------------|-------------|---------| | Connect | 10s | **10s** (unchanged) | Connection failures are typically fast to detect | | Read | 60s | **600s (10 min)** | Allows slow API responses, large file downloads | | Write | 20s | **600s (10 min)** | Allows large file uploads, slow request processing | #### 2. **Exposed Configuration to Docker Deployment** Added environment variables to .env.example and docker-compose.yaml: ```bash # HTTP request node timeout configuration # Maximum timeout values (in seconds) that users can set in HTTP request nodes # - Connect timeout: Time to wait for establishing connection (default: 10s) # - Read timeout: Time to wait for receiving response data (default: 600s, 10 minutes) # - Write timeout: Time to wait for sending request data (default: 600s, 10 minutes) HTTP_REQUEST_MAX_CONNECT_TIMEOUT=10 HTTP_REQUEST_MAX_READ_TIMEOUT=600 HTTP_REQUEST_MAX_WRITE_TIMEOUT=600 ``` Self-hosted users can now easily customize these values by setting environment variables. #### 3. **Enhanced Frontend to Respect Backend Configuration** Updated the frontend timeout component to: - ✅ Dynamically read maximum timeout values from backend configuration - ✅ Use proper fallback chain: `payload.max_X_timeout` → `backend_config.max_X_timeout` → `hardcoded_default` - ✅ Respect backend as the source of truth for timeout limits - ✅ Maintain minimum validation (1 second) to prevent invalid inputs #### 4. **Improved Test Coverage** - Added `test_http_timeout_defaults()` to verify new default values - Updated existing tests to use custom values for clarity - All 13 config tests passing ✅ ### 📊 Changes **Files Modified:** 5 files, +51 insertions, -13 deletions - __init__.py - Updated default timeout values - .env.example - Added timeout configuration with documentation - docker-compose.yaml - Added environment variable mappings - index.tsx - Enhanced to read backend config - test_dify_config.py - Added test coverage for new defaults ### 🧪 Testing **All tests passing:** ```bash ✅ test_dify_config - Validates custom configuration ✅ test_http_timeout_defaults - Validates new default values ✅ test_flask_configs - Validates Flask integration ✅ test_inner_api_config_exist - Validates inner API config ✅ ... (13 tests total, all passed) ``` **Manual testing scenarios:** - ✅ HTTP node with default timeouts works correctly - ✅ Custom timeout values via environment variables are respected - ✅ Frontend displays correct maximum values from backend - ✅ Validation prevents values < 1 second - ✅ Users can configure timeouts beyond previous hard limits ### 🎯 Benefits 1. **Better defaults** - 10-minute timeouts are more suitable for real-world API integrations 2. **Full configurability** - Self-hosted users can customize via environment variables 3. **Clear documentation** - Configuration options are now documented in .env.example 4. **Proper separation of concerns** - Backend controls security boundaries, frontend provides UX 5. **Backward compatible** - Existing workflows continue to work without changes ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:49:37 -05:00
yindo closed this issue 2026-02-21 20:49:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31519