Skip to content

Fix: CLI hanging issue - implement resource cleanup #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025

Conversation

github-actions[bot]
Copy link

Fix CLI Hanging Issue

Problem

The mycoder CLI sometimes hangs and doesn't return to the shell even after showing a performance summary. This is caused by unresolved promises, open browser sessions, and running shell processes that prevent the Node.js process from exiting.

Solution

This PR implements a comprehensive cleanup system that ensures all resources are properly released before the CLI exits:

  1. Added a new cleanup utility (packages/cli/src/utils/cleanup.ts) that:

    • Closes all browser sessions
    • Terminates all shell processes
    • Adds a force exit failsafe
  2. Updated the BrowserManager to:

    • Store a reference globally for cleanup access
    • Use beforeExit for async cleanup
    • Handle SIGINT properly
  3. Modified the main CLI entry point to:

    • Call cleanup functions in the finally block
    • Set up a force exit after a timeout as a failsafe

Testing

This change can be tested by running the CLI with commands that use browser or shell tools and verifying that the CLI properly exits after completion.

Fixes #141
Related to #202

- Add cleanup utility to terminate browser sessions and shell processes\n- Update BrowserManager with better process exit handling\n- Add force exit as a failsafe\n- Export necessary components for cleanup\n\nFixes #141
Copy link
Author

🎉 This PR is included in version mycoder-agent-v1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Author

🎉 This PR is included in version mycoder-v1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sometimes mycoder will quit (and even give a performance summary), but not return to shell
1 participant