Skip to content
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

In Bundler and Watch mode, exit if stdin closes (implying parent process died) #11889

Open
natrys opened this issue Jun 15, 2024 · 0 comments
Open
Labels
bundler Something to do with the bundler enhancement New feature or request

Comments

@natrys
Copy link

natrys commented Jun 15, 2024

What is the problem this feature would solve?

It's not uncommon for a bundler to be launched in watch mode by some higher level web framework. Sometimes these frameworks are running on runtimes that do not expose OS process control APIs for portability reasons. Speaking for BEAM VM that powers Phoenix web framework e.g., if Bun is launched by Phoenix and then Phoenix dies, that just leaves a dangling Bun process.

It would be nice to have Bun itself monitor its own stdin in the Bundler and Watch mode and exit itself when stdin closes, because that's the only conventional and cross-platform way of knowing that parent process died.

What is the feature you are proposing to solve the problem?

To be minimally obtrusive, we can only enact this behaviour when stdin is not a TTY. This is what esbuild does.

This seems to be a good survey on what many tools does with regard to this behaviour: tailwindlabs/tailwindcss#9264 (comment)

What alternatives have you considered?

Currently the workaround is to use a wrapper program/script with child process control capability to do this on behalf of Phoenix. It can even be another Bun program, which is how one integration with Phoenix does it. But if we can avoid an extra process, I think we should.

@natrys natrys added the enhancement New feature or request label Jun 15, 2024
@paperdave paperdave added the bundler Something to do with the bundler label Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bundler Something to do with the bundler enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants