Skip to content

fix(chatflow): cancel watchdog on workflow terminal events - #45029

Merged
zyssyz123 merged 1 commit into
mainfrom
fix/inf-438-chatflow-watchdog
Oct 29, 2026
Merged

zyssyz123 merged 1 commit into
mainfrom
fix/inf-438-chatflow-watchdog

Conversation

@zyssyz123

Copy link
Copy Markdown
Contributor

Summary

Chatflow success, partial success and failure could finish the response pipeline while leaving the execution coordinator RUNNING. Its watchdog then retained the queue and task context until the execution timeout.

Handle all three workflow terminal events through the existing terminal cleanup path, marking the coordinator TERMINAL and cancelling its watchdog. Pause and response-detachment behavior are preserved.

Related: INF-438.

Validation

  • The three terminal-event regressions failed against the original implementation; 44 related queue/coordinator tests pass with the fix, including pause and response detachment. The new regressions exercise real threading.Timer cancellation and thread exit.
  • Six isolated dev cases exercised success, failure and partial success before and after the fix, using Celery eager execution with the real GraphEngine, database, Redis, gevent and Sentry integrations with a discard transport. Original runs retained a live Timer, coordinator and queue after GC; patched runs reached TERMINAL and released those objects.
  • Targeted Ruff, formatting, Pyrefly and test-double policy checks pass.

Dev validation does not cover broker scheduling or high worker concurrency. The patch has not been deployed to shared workers; releasing these references does not guarantee an immediate RSS decrease.

Screenshots

N/A — backend execution lifecycle fix.

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 verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

From Codex

@github-actions github-actions Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Oct 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 80.25% 80.25% +0.00%
Strict coverage 79.93% 79.94% +0.00%
Typed symbols 77,239 77,246 +7
Untyped symbols 19,088 19,088 0
Modules 3988 3988 0

@codecov

codecov Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.62%. Comparing base (70975c1) to head (f077a7e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #45029   +/-   ##
=======================================
  Coverage   59.62%   59.62%           
=======================================
  Files        6011     6011           
  Lines      377116   377116           
  Branches    76358    76358           
=======================================
+ Hits       224848   224852    +4     
+ Misses     146276   146271    -5     
- Partials     5992     5993    +1     
Flag Coverage Δ
api 89.41% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zyssyz123
zyssyz123 enabled auto-merge October 29, 2026 04:32

@MRZHUH MRZHUH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed f077a7e. No blocking correctness issues found. All three workflow terminal events now enter the existing cleanup path after enqueueing the event, cancelling the watchdog while preserving pause and response-detachment behavior. The downstream handlers still produce the final responses directly, and the regression tests exercise real Timer cancellation and thread exit.

Validation: CI API unit tests (24,293 passed, 4 skipped), controller and integration tests, Python style, and Pyrefly checks passed. codecov/patch also passed. Local tests were not rerun for this review.

Outstanding CI caveat: codecov/project is still failing (56.89% versus 59.62% on the base). This approval covers the code change; the aggregate coverage failure still needs resolution before merge.

@zyssyz123
zyssyz123 added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit 78e7fce Oct 29, 2026
51 checks passed
@zyssyz123
zyssyz123 deleted the fix/inf-438-chatflow-watchdog branch October 29, 2026 04:40
@laipz8200 laipz8200 mentioned this pull request Nov 3, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants