Skip to content

From Discord: Maintaining CLI Session for Iterative Development with bun --watch #3696

@effect-bot

Description

@effect-bot

Summary

Summary:

  • User Issue: @Nikivi is experiencing issues with a CLI-based development workflow using bun --watch and @effect/cli. The process quits immediately upon saving a file, ignoring the --watch flag.

  • Rapid Iterations and Insight:

    • @maxwellbrown suggests switching from BunRuntime.runMain to Effect.runPromise.
    • @Nikivi confirms that switching to Effect.runPromise works but raises concerns about potential drawbacks.
    • @MichaelArnaldi points out that using Effect.runPromise without proper cleanup can lead to resource leakage.
  • Main Technical Points:

    • Effect.runPromise in development bypasses the process exit handlers, causing potential resource leaks.
    • The runMain method is crucial for setting up event listeners to handle process signals for clean exits.
    • There is a discussion around customizing the runtime setup to work in both development (--watch) and production environments.
  • Key Actionable Insights:

    • In Development: Use Effect.runPromise to prevent immediate process exit when running in watch mode.
    • In Production: Switch back to BunRuntime.runMain to ensure proper cleanup and resource management.
    • Potential use of environment variables to conditionally switch between runPromise and runMain.
  • Investigation and Fixes:

    • @TimSmart creates a PR to address the issue by changing the process.exit behavior.
    • Discussion about understanding why unregistering signal handlers did not allow the process to complete naturally.

Key Takeaways:

  1. Temporary Solution: Use Effect.runPromise in watch mode for development but be aware of potential resource leaks.
  2. Proper Cleanup: Ensure proper event listener binding and cleanup strategies in production using runMain.
  3. Community Collaboration: Contributions from community members and maintainers helped to quickly identify and propose solutions.
  4. Further Investigation: Suggested creating a minimal reproduction and exploring why certain signal handling behaviors prevented clean process termination.

Discord thread

https://discord.com/channels/795981131316985866/1287372464548216883

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions