dify icon indicating copy to clipboard operation
dify copied to clipboard

feat: add support for request timeout settings in the HTTP request node.

Open majian159 opened this issue 9 months ago • 6 comments

Description

Backend

  1. Add Timeout type and timeout field to HttpRequestNodeData
  2. Modify the HTTP_REQUEST_DEFAULT_TIMEOUT setting to have a connection timeout of 10 seconds, read timeout of 60 seconds, and write timeout of 20 seconds
  3. Apply the timeout configuration on httpx

Frontend

  1. Add readOnly, min, max attributes to the Input component
  2. Add Timeout settings to the HTTP Request Node
  3. Add i18n information

Fixes #3806 #3808

Type of Change

Please delete options that are not relevant.

  • [x] New feature (non-breaking change which adds functionality)

How Has This Been Tested?

I am debugging locally to ensure that the timeout parameter is passed into httpx and that the request is successful.

Suggested Checklist:

  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] My changes generate no new warnings
  • [x] I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
  • [ ] optional I have made corresponding changes to the documentation
  • [ ] optional I have added tests that prove my fix is effective or that my feature works
  • [ ] optional New and existing unit tests pass locally with my changes

majian159 avatar Apr 25 '24 14:04 majian159

Hello thanks for your contribution, please add my wechat: crazyphage. I will invite you to our developer group chat.

crazywoola avatar Apr 26 '24 01:04 crazywoola

I suggest a max timeout to avoid network blocking issues, otherwise it brings a memory leak problem.

Yeuoly avatar Apr 26 '24 07:04 Yeuoly

I suggest a max timeout to avoid network blocking issues, otherwise it brings a memory leak problem.

The timeout period can vary depending on different business scenario requirements. Should we impose this limit on the frontend or the backend? How does 10 minutes sound?

majian159 avatar Apr 26 '24 09:04 majian159

I suggest a max timeout to avoid network blocking issues, otherwise it brings a memory leak problem.

The timeout period can vary depending on different business scenario requirements. Should we impose this limit on the frontend or the backend? How does 10 minutes sound?

I prefer using environment variables to specify default max timeout of it, how do you think of this? we can use 10 minutes by default.

Yeuoly avatar Apr 28 '24 04:04 Yeuoly

I suggest a max timeout to avoid network blocking issues, otherwise it brings a memory leak problem.

The timeout period can vary depending on different business scenario requirements. Should we impose this limit on the frontend or the backend? How does 10 minutes sound?

I prefer using environment variables to specify default max timeout of it, how do you think of this? we can use 10 minutes by default.

If we use environment variables to set the timeout, we need to consider the maximum value allowed by the frontend components. Do we need to provide an environment variable at both the API layer and the frontend layer?

majian159 avatar Apr 28 '24 06:04 majian159

@Yeuoly Add environment variables HTTP_REQUEST_MAX_CONNECT_TIMEOUT, HTTP_REQUEST_MAX_READ_TIMEOUT, HTTP_REQUEST_MAX_WRITE_TIMEOUT to limit the maximum timeout duration of HTTP requests. The default values are respectively 5 minutes, 10 minutes, and 10 minutes.

majian159 avatar Apr 28 '24 14:04 majian159