Workflow status STUCK as "running" with weChat Cloud functions, while the result is already successfully generated in fact. please help fix~ #8627

Closed
opened 2026-02-21 18:26:43 -05:00 by yindo · 6 comments
Owner

Originally created by @Zerglingzl on GitHub (Feb 25, 2025).

Originally assigned to: @laipz8200 on GitHub.

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.3

Cloud or Self Hosted

Cloud

Steps to reproduce

I encountered the same issue “thread #12798” mentioned and sincerely hope that Dify can resolve it as soon as possible; otherwise, it will significantly impact our product’s user experience.

My situation might be somewhat unique, yet it makes reproducing the issue even easier—basically, it occurs over 50% of the time.

The business logic is as follows:
1. I use WeChat cloud functions to call Dify’s workflow API. Once the workflow starts running, to avoid waiting too long for a result, the cloud function exits and is terminated.
2. I use WeChat cloud functions to poll the workflow status periodically. If the status becomes “succeed,” I retrieve the result.

As a result, the problem mentioned in “thread #12798” keeps occurring, causing the workflow status to remain stuck on “running.” In reality, however, the workflow has completed (log analysis shows that the final step has produced results), and the tokens for the large model have already been consumed, which is extremely frustrating.

for Debug, there are some workflow run IDs (which are still "running") of mine:

1f692007-1cb1-4dc5-8a61-7b2637309513
1666d166-623f-4c60-9d82-e0d1b2ced4bd
f7f184e0-460a-4dab-9849-75b528f16e99
72f73925-372c-422b-b547-9c93a49bf2dc

BTW, I'm using SaaS Dify 0.15.3.

@kazuhisa-wada @WeakX @takatost

✔️ Expected Behavior

No response

Actual Behavior

No response

Originally created by @Zerglingzl on GitHub (Feb 25, 2025). Originally assigned to: @laipz8200 on GitHub. ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.15.3 ### Cloud or Self Hosted Cloud ### Steps to reproduce I encountered the same issue “thread #12798” mentioned and sincerely hope that Dify can resolve it as soon as possible; otherwise, it will significantly impact our product’s user experience. My situation might be somewhat unique, yet it makes reproducing the issue even easier—basically, it occurs over 50% of the time. The business logic is as follows: 1. I use WeChat cloud functions to call Dify’s workflow API. Once the workflow starts running, to avoid waiting too long for a result, the cloud function exits and is terminated. 2. I use WeChat cloud functions to poll the workflow status periodically. If the status becomes “succeed,” I retrieve the result. As a result, the problem mentioned in “thread #12798” keeps occurring, causing the workflow status to remain stuck on “running.” In reality, however, the workflow has completed (log analysis shows that the final step has produced results), and the tokens for the large model have already been consumed, which is extremely frustrating. for Debug, there are some workflow run IDs (which are still "running") of mine: 1f692007-1cb1-4dc5-8a61-7b2637309513 1666d166-623f-4c60-9d82-e0d1b2ced4bd f7f184e0-460a-4dab-9849-75b528f16e99 72f73925-372c-422b-b547-9c93a49bf2dc BTW, I'm using SaaS Dify 0.15.3. @kazuhisa-wada @WeakX @takatost ### ✔️ Expected Behavior _No response_ ### ❌ Actual Behavior _No response_
yindo added the 🐞 bug🌊 feat:workflow labels 2026-02-21 18:26:43 -05:00
yindo closed this issue 2026-02-21 18:26:43 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 25, 2025):

The issue you're experiencing, where the workflow status remains stuck as "running" despite the result being successfully generated, is related to network disconnections during workflow execution. This causes the main thread responsible for database operations to be terminated. To resolve this in Dify version 0.15.3, you should:

  1. Decouple the database operations from the main thread by moving them to a separate thread.
  2. Create a new dedicated thread for database operations.
  3. Move the database update operations from the main thread to this new thread.

This approach ensures that database updates continue even if the main thread is killed due to network disconnection, particularly in streaming mode. This solution aligns with the architecture changes recommended in Dify v0.15.1, where the main thread handles execution threads and message listening, while a new dedicated thread manages database updates [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Feb 25, 2025): <!-- Answer --> The issue you're experiencing, where the workflow status remains stuck as "running" despite the result being successfully generated, is related to network disconnections during workflow execution. This causes the main thread responsible for database operations to be terminated. To resolve this in Dify version 0.15.3, you should: 1. Decouple the database operations from the main thread by moving them to a separate thread. 2. Create a new dedicated thread for database operations. 3. Move the database update operations from the main thread to this new thread. This approach ensures that database updates continue even if the main thread is killed due to network disconnection, particularly in streaming mode. This solution aligns with the architecture changes recommended in Dify v0.15.1, where the main thread handles execution threads and message listening, while a new dedicated thread manages database updates <sup>[[1]](https://github.com/langgenius/dify/issues/12798)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/26c79ea6-5953-4462-84c5-6cb460973476?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/26c79ea6-5953-4462-84c5-6cb460973476?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/26c79ea6-5953-4462-84c5-6cb460973476?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/26c79ea6-5953-4462-84c5-6cb460973476?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/26c79ea6-5953-4462-84c5-6cb460973476?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/26c79ea6-5953-4462-84c5-6cb460973476?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/26c79ea6-5953-4462-84c5-6cb460973476?feedback_type=other)</sup>
Author
Owner

@Zerglingzl commented on GitHub (Feb 25, 2025):

@dosu I can't apply your solution since:
1, I'm using Cloud version of Dify
2, I can't prevent weChat cloud functions from termination.

For my understanding, Workflow should have an “asynchronous execution” mechanism (especially for workflows that run for an long period):
1. The caller initiates the workflow.
2. The workflow runs independently of the caller.
3. The caller retrieves the results as needed.

This mechanism should be relatively simple and is particularly well-suited for third-party platforms that require batch processing.

@Zerglingzl commented on GitHub (Feb 25, 2025): @dosu I can't apply your solution since: 1, I'm using Cloud version of Dify 2, I can't prevent weChat cloud functions from termination. For my understanding, Workflow should have an “asynchronous execution” mechanism (especially for workflows that run for an long period): 1. The caller initiates the workflow. 2. The workflow runs independently of the caller. 3. The caller retrieves the results as needed. This mechanism should be relatively simple and is particularly well-suited for third-party platforms that require batch processing.
Author
Owner

@dosubot[bot] commented on GitHub (Feb 25, 2025):

To implement an asynchronous execution mechanism in the Cloud version of Dify, you can use a queue system to handle tasks independently of the caller. This approach allows the workflow to run asynchronously, enabling the caller to retrieve results as needed without being affected by the termination of WeChat cloud functions.

Here's a basic outline of how you can achieve this:

  1. Initiate the Workflow: When the caller initiates the workflow, add the task to a queue instead of processing it immediately.

  2. Process the Workflow Asynchronously: Use a worker service, such as Celery, to process tasks from the queue. This allows the workflow to run independently of the caller. You can start a Celery worker with the following command:

    celery -A app.celery worker -P gevent -c 1 -Q dataset,generation,mail,ops_trace --loglevel INFO
    

    This command sets up a Celery worker to handle tasks asynchronously, ensuring that the workflow continues to run even if the caller disconnects [1].

  3. Retrieve Results: The caller can periodically check the status of the workflow and retrieve results once they are available. This can be done by polling the workflow status or using a callback mechanism to notify the caller when the workflow is complete.

By using this approach, you can ensure that workflows run independently and asynchronously, which is particularly useful for integrating with third-party platforms like WeChat that require batch processing.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot[bot] commented on GitHub (Feb 25, 2025): <!-- Answer --> To implement an asynchronous execution mechanism in the Cloud version of Dify, you can use a queue system to handle tasks independently of the caller. This approach allows the workflow to run asynchronously, enabling the caller to retrieve results as needed without being affected by the termination of WeChat cloud functions. Here's a basic outline of how you can achieve this: 1. **Initiate the Workflow**: When the caller initiates the workflow, add the task to a queue instead of processing it immediately. 2. **Process the Workflow Asynchronously**: Use a worker service, such as Celery, to process tasks from the queue. This allows the workflow to run independently of the caller. You can start a Celery worker with the following command: ```bash celery -A app.celery worker -P gevent -c 1 -Q dataset,generation,mail,ops_trace --loglevel INFO ``` This command sets up a Celery worker to handle tasks asynchronously, ensuring that the workflow continues to run even if the caller disconnects <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/README.md)</sup>. 3. **Retrieve Results**: The caller can periodically check the status of the workflow and retrieve results once they are available. This can be done by polling the workflow status or using a callback mechanism to notify the caller when the workflow is complete. By using this approach, you can ensure that workflows run independently and asynchronously, which is particularly useful for integrating with third-party platforms like WeChat that require batch processing. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/682b731c-1d90-4723-aec7-0f87a735d183?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/682b731c-1d90-4723-aec7-0f87a735d183?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/682b731c-1d90-4723-aec7-0f87a735d183?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/682b731c-1d90-4723-aec7-0f87a735d183?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/682b731c-1d90-4723-aec7-0f87a735d183?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/682b731c-1d90-4723-aec7-0f87a735d183?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/682b731c-1d90-4723-aec7-0f87a735d183?feedback_type=other)</sup>
Author
Owner

@Zerglingzl commented on GitHub (Feb 26, 2025):

update: I tried Ali cloud functions yesterday, unfortunately the issue REMAINS the same. it seems that this issue affects ALL BAAS type of backend caller, including weChat cloud functions, Ali cloud functions, Amazon cloud functions, etc. Our business stuck in that bug now, please fix it or any suggestions , thanks a lot!

@Zerglingzl commented on GitHub (Feb 26, 2025): update: I tried Ali cloud functions yesterday, unfortunately the issue REMAINS the same. it seems that this issue affects ALL BAAS type of backend caller, including weChat cloud functions, Ali cloud functions, Amazon cloud functions, etc. Our business stuck in that bug now, please fix it or any suggestions , thanks a lot!
Author
Owner

@Zerglingzl commented on GitHub (Feb 26, 2025):

update2: call back (when workflow is done) would be the perfect solution. Of cause that means a lot of work for dify engineer...

@Zerglingzl commented on GitHub (Feb 26, 2025): update2: call back (when workflow is done) would be the perfect solution. Of cause that means a lot of work for dify engineer...
Author
Owner

@dosubot[bot] commented on GitHub (Mar 30, 2025):

Hi, @Zerglingzl. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • The workflow status remains "running" when using WeChat cloud functions with Dify's workflow API.
  • A suggested solution to decouple database operations was not applicable due to the Cloud version and WeChat's nature.
  • The issue also affects other cloud functions like Ali and Amazon.
  • A callback mechanism was suggested as an ideal solution to indicate workflow completion.
  • The issue is unresolved and significantly impacts your business.

Next Steps:

  • Please let us know if this issue is still relevant to the latest version of the Dify repository by commenting here.
  • If there is no further activity, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Mar 30, 2025): Hi, @Zerglingzl. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - The workflow status remains "running" when using WeChat cloud functions with Dify's workflow API. - A suggested solution to decouple database operations was not applicable due to the Cloud version and WeChat's nature. - The issue also affects other cloud functions like Ali and Amazon. - A callback mechanism was suggested as an ideal solution to indicate workflow completion. - The issue is unresolved and significantly impacts your business. **Next Steps:** - Please let us know if this issue is still relevant to the latest version of the Dify repository by commenting here. - If there is no further activity, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#8627