dify icon indicating copy to clipboard operation
dify copied to clipboard

[Bug] Human Input node timeout can leave workflow paused when resume publication fails

Open mikamikasuki opened this issue 3 weeks ago • 3 comments

Self Checks

  • [x] I have read the Contributing Guide and Language Policy.
  • [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report, otherwise it will be closed.
  • [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

main (05f3723c6f4b11441192eff9d0627edf8b425348), reproduced from source

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

On Dify main at 05f3723c6f4b11441192eff9d0627edf8b425348, create a workflow containing a Human Input node and let its node-level deadline expire while the global workflow deadline remains in the future.

When the timeout handler commits the form as TIMEOUT, make resume_app_execution.apply_async(...) fail (for example, with a broker connection error). The same delivery ordering is used by legacy and v2 Human Input timeout paths.

The periodic timeout scan only selects waiting forms, so after the failed publication it no longer selects this form for another resume attempt.

✔️ Expected Behavior

A node-level timeout should eventually resume the paused workflow even when the broker is temporarily unavailable.

❌ Actual Behavior

The Human Input form is committed as TIMEOUT, but the workflow run remains PAUSED. Since the timeout form is no longer waiting, later timeout scans do not retry publishing its resume task, leaving the run paused indefinitely.

mikamikasuki avatar Nov 13 '26 18:11 mikamikasuki

There is an additional failure-handling distinction at the reported revision:

  • Legacy: HumanInputService.enqueue_resume() catches and logs publication exceptions without re-raising, so the timeout task can appear successful despite losing the resume request. [1]
  • V2: publication happens after the transaction exits, and the exception propagates. However, simply retrying that handler is insufficient for an already-settled form: it reloads only waiting forms before deciding whether to enqueue resume. [2]

The legacy global-timeout scan is not a fallback for that settled form either, because its WAITING filter also gates global-expiry handling. [3]

This suggests the maintainer fix needs a durable way to retry the pending resume independently of the form's waiting status. A useful regression case for both paths would fail publication once, restore the broker, then verify a later scan or recovery attempt resumes the same run without resetting the form to WAITING.

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about dify

dosubot[bot] avatar Nov 13 '26 18:11 dosubot[bot]

Spot on catch. It's a classic dual-write race where the DB commits the form as TIMEOUT before the Celery dispatch succeeds, leaving the parent workflow_runs stuck in PAUSED with no retry path.

Upstream, the cleanest fix is either rolling back the form status on broker publish failure so the existing sweep retries it, or adding a reconciliation sweep that queries HumanInputForm.status == 'TIMEOUT' alongside WorkflowRun.status == 'PAUSED'.

If you're already preparing a PR for this, happy to help review it.

grinem avatar Nov 13 '26 21:11 grinem

I'll take this one. Plan: reproduce the dual-write race (form committed as TIMEOUT while resume_app_execution.apply_async fails), then fix it so a failed publish doesn't strand the workflow run in PAUSED — rolling back the form status on publish failure so the existing timeout sweep retries it. I'll add a unit test covering the broker-failure path in the human-input timeout flow and run the adjacent test_human_input_service / human_input_v2 suites.

jimmyallinai avatar Nov 16 '26 01:11 jimmyallinai