Skip to content

fix(dingtalk): drain inbound background tasks - #5464

Merged
Re-bin merged 2 commits into
HKUDS:mainfrom
yu-xin-c:contrib/dingtalk-background-task-lifecycle
Aug 30, 2026
Merged

fix(dingtalk): drain inbound background tasks#5464
Re-bin merged 2 commits into
HKUDS:mainfrom
yu-xin-c:contrib/dingtalk-background-task-lifecycle

Conversation

@yu-xin-c

Copy link
Copy Markdown
Contributor

Summary

  • observe DingTalk inbound task completion instead of only discarding task handles
  • retrieve and log unexpected task failures with their traceback
  • treat cancellation as normal and await every tracked task during channel shutdown

Why

The DingTalk stream callback forwards accepted messages through background tasks so it can acknowledge the platform promptly. The previous completion callback removed each task from the registry without retrieving its result, turning message-processing failures into detached Task exception was never retrieved warnings.

Shutdown also cancelled and immediately cleared the registry without awaiting the tasks. DingTalkChannel.stop() could therefore return while inbound work was still cancelling.

The shared completion callback now owns terminal observation, while shutdown snapshots, cancels, and gathers the same tracked task set before returning.

Validation

  • regression on unmodified main: 2 failed (Task exception was never retrieved; task still cancelling after stop())
  • focused lifecycle regressions: 2 passed
  • full DingTalk test module: 39 passed
  • pytest -q -n auto: 6151 passed, 23 skipped
  • ruff check on changed files
  • basedpyright nanobot/channels/dingtalk/runtime.py: 0 errors
  • git diff --check

Closes #5463

@yu-xin-c
yu-xin-c marked this pull request as ready for review August 21, 2026 07:17
@chengyongru chengyongru added bug Something isn't working channel fix priority: p2 Normal backlog: minor bug, enhancement, docs, cleanup, edge case, or unvalidated proposal. test labels Aug 21, 2026
@Re-bin
Re-bin force-pushed the contrib/dingtalk-background-task-lifecycle branch from 1305107 to 0b4c19e Compare August 30, 2026 09:46

@Re-bin Re-bin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. DingTalk inbound tasks now have observed terminal states, shutdown waits for tracked cancellations, and late file/rich-text handlers cannot create new work after shutdown begins.

Focused lifecycle regressions cover failure, cancellation, and the download/stop race, and all required checks are green on the current head based on the latest main.

@Re-bin
Re-bin merged commit d019658 into HKUDS:main Aug 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working channel fix priority: p2 Normal backlog: minor bug, enhancement, docs, cleanup, edge case, or unvalidated proposal. test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DingTalk does not observe or drain inbound background tasks

3 participants