Skip to content

Conversation

@huangdijia
Copy link
Member

Summary

  • Add CoordinatorManager cleanup in the finally block of command execution
  • Ensure proper coordinator cleanup after command execution completes
  • Wrap cleanup call in try-catch to prevent exceptions from interrupting the cleanup flow

Changes

  • Added CoordinatorManager::until(Constants::WORKER_EXIT)->resume() in the finally block
  • Added necessary imports for Hyperf\Coordinator\Constants and Hyperf\Coordinator\CoordinatorManager
  • Wrapped the cleanup call in try-catch block to handle any potential exceptions gracefully

Test plan

  • Verify command execution works normally
  • Confirm coordinator cleanup is called after command execution
  • Test that exceptions in cleanup don't affect command execution flow

- Add CoordinatorManager::until(Constants::WORKER_EXIT)->resume() in finally block
- Ensure proper cleanup of coordinators after command execution
- Wrap in try-catch to prevent exceptions from interrupting cleanup flow
@huangdijia huangdijia requested a review from Copilot September 25, 2025 06:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds coordinator cleanup functionality to command execution by implementing CoordinatorManager::until(Constants::WORKER_EXIT)->resume() in the finally block of command execution. This ensures proper cleanup of coordinators after commands complete while preventing cleanup exceptions from interfering with the command flow.

  • Added coordinator cleanup in the command execution finally block with proper exception handling
  • Added the hyperf/coordinator dependency to the command package
  • Deprecated the existing ResumeExitCoordinatorListener as it's being replaced by this new implementation

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/command/src/Command.php Added coordinator cleanup logic in finally block with try-catch protection
src/command/composer.json Added hyperf/coordinator dependency
src/coordinator/src/Listener/ResumeExitCoordinatorListener.php Deprecated listener and commented out its functionality
CHANGELOG-3.1.md Added changelog entry for the optimization

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@limingxinleo limingxinleo merged commit 6f4c25b into hyperf:master Sep 25, 2025
71 checks passed
@huangdijia huangdijia deleted the fix/command-coordinator-cleanup branch September 25, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants