[PR #4395] Fix HTTP REQUEST NODE is always waiting but endpoint have responsed #24514

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

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

State: closed
Merged: Yes


Description

Fixes issue (https://github.com/langgenius/dify/issues/4386)

In the PR(https://github.com/langgenius/dify/pull/4360), I use httpx.Response.headers | requests.Response.headers instead of HttpExecutorResponse.headers, because they are both a version of case-insensitive multi-dict. But cause this issue.

When we run the whole workflow, it has some json encoder/decoder error:

Traceback (most recent call last):
  File "C:\Users\hejl\anaconda3\envs\dify\lib\site-packages\werkzeug\wsgi.py", line 256, in __next__
    return self._next()
  File "C:\Users\hejl\anaconda3\envs\dify\lib\site-packages\werkzeug\wrappers\response.py", line 32, in _iter_encoded
    for item in iterable:
  File "C:\Users\hejl\anaconda3\envs\dify\lib\site-packages\flask\helpers.py", line 113, in generator
    yield from gen
  File "C:\Users\hejl\PycharmProjects\dify\api\libs\helper.py", line 156, in generate
    yield from response
  File "C:\Users\hejl\PycharmProjects\dify\api\core\app\apps\base_app_generate_response_converter.py", line 28, in _generate
    for chunk in cls.convert_stream_full_response(response):
  File "C:\Users\hejl\PycharmProjects\dify\api\core\app\apps\workflow\generate_response_converter.py", line 45, in convert_stream_full_response
    for chunk in stream_response:
  File "C:\Users\hejl\PycharmProjects\dify\api\core\app\apps\workflow\generate_task_pipeline.py", line 148, in _to_stream_response
    for stream_response in generator:
  File "C:\Users\hejl\PycharmProjects\dify\api\core\app\apps\workflow\generate_task_pipeline.py", line 188, in _process_stream_response
    workflow_node_execution = self._handle_node_finished(event)
  File "C:\Users\hejl\PycharmProjects\dify\api\core\app\task_pipeline\workflow_cycle_manage.py", line 448, in _handle_node_finished
    workflow_node_execution = self._workflow_node_execution_success(
  File "C:\Users\hejl\PycharmProjects\dify\api\core\app\task_pipeline\workflow_cycle_manage.py", line 223, in _workflow_node_execution_success
    workflow_node_execution.outputs = json.dumps(outputs) if outputs else None
  File "C:\Users\hejl\anaconda3\envs\dify\lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "C:\Users\hejl\anaconda3\envs\dify\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Users\hejl\anaconda3\envs\dify\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "C:\Users\hejl\anaconda3\envs\dify\lib\site-packages\frozendict\__init__.py", line 31, in default
    return BaseJsonEncoder.default(self, obj)
  File "C:\Users\hejl\anaconda3\envs\dify\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Headers is not JSON serializable

So the simplest way to fix that is to still use origin dict. I am sorry for not test run the whole workflow, only test run the http request node.

Please review it, thank you.

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • TODO

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • 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
**Original Pull Request:** https://github.com/langgenius/dify/pull/4395 **State:** closed **Merged:** Yes --- # Description Fixes issue (https://github.com/langgenius/dify/issues/4386) In the PR(https://github.com/langgenius/dify/pull/4360), I use `httpx.Response.headers | requests.Response.headers` instead of `HttpExecutorResponse.headers`, because they are both a version of case-insensitive multi-dict. But cause this issue. When we run the whole workflow, it has some json encoder/decoder error: ``` Traceback (most recent call last): File "C:\Users\hejl\anaconda3\envs\dify\lib\site-packages\werkzeug\wsgi.py", line 256, in __next__ return self._next() File "C:\Users\hejl\anaconda3\envs\dify\lib\site-packages\werkzeug\wrappers\response.py", line 32, in _iter_encoded for item in iterable: File "C:\Users\hejl\anaconda3\envs\dify\lib\site-packages\flask\helpers.py", line 113, in generator yield from gen File "C:\Users\hejl\PycharmProjects\dify\api\libs\helper.py", line 156, in generate yield from response File "C:\Users\hejl\PycharmProjects\dify\api\core\app\apps\base_app_generate_response_converter.py", line 28, in _generate for chunk in cls.convert_stream_full_response(response): File "C:\Users\hejl\PycharmProjects\dify\api\core\app\apps\workflow\generate_response_converter.py", line 45, in convert_stream_full_response for chunk in stream_response: File "C:\Users\hejl\PycharmProjects\dify\api\core\app\apps\workflow\generate_task_pipeline.py", line 148, in _to_stream_response for stream_response in generator: File "C:\Users\hejl\PycharmProjects\dify\api\core\app\apps\workflow\generate_task_pipeline.py", line 188, in _process_stream_response workflow_node_execution = self._handle_node_finished(event) File "C:\Users\hejl\PycharmProjects\dify\api\core\app\task_pipeline\workflow_cycle_manage.py", line 448, in _handle_node_finished workflow_node_execution = self._workflow_node_execution_success( File "C:\Users\hejl\PycharmProjects\dify\api\core\app\task_pipeline\workflow_cycle_manage.py", line 223, in _workflow_node_execution_success workflow_node_execution.outputs = json.dumps(outputs) if outputs else None File "C:\Users\hejl\anaconda3\envs\dify\lib\json\__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "C:\Users\hejl\anaconda3\envs\dify\lib\json\encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "C:\Users\hejl\anaconda3\envs\dify\lib\json\encoder.py", line 257, in iterencode return _iterencode(o, 0) File "C:\Users\hejl\anaconda3\envs\dify\lib\site-packages\frozendict\__init__.py", line 31, in default return BaseJsonEncoder.default(self, obj) File "C:\Users\hejl\anaconda3\envs\dify\lib\json\encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type Headers is not JSON serializable ``` So the simplest way to fix that is to still use origin dict. I am sorry for not test run the whole workflow, only test run the http request node. Please review it, thank you. ## Type of Change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [ ] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement - [ ] Dependency upgrade # How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [ ] TODO # Suggested Checklist: - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] My changes generate no new warnings - [ ] 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
yindo added the pull-request label 2026-02-21 20:23:09 -05:00
yindo closed this issue 2026-02-21 20:23:09 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#24514