fix(dingtalk): drain inbound background tasks - #5464
Merged
Re-bin merged 2 commits intoAug 30, 2026
Conversation
yu-xin-c
marked this pull request as ready for review
August 21, 2026 07:17
Re-bin
force-pushed
the
contrib/dingtalk-background-task-lifecycle
branch
from
August 30, 2026 09:46
1305107 to
0b4c19e
Compare
Re-bin
approved these changes
Aug 30, 2026
Re-bin
left a comment
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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 retrievedwarnings.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
main: 2 failed (Task exception was never retrieved; task still cancelling afterstop())pytest -q -n auto: 6151 passed, 23 skippedruff checkon changed filesbasedpyright nanobot/channels/dingtalk/runtime.py: 0 errorsgit diff --checkCloses #5463