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

Cli exits process instantly when called by turborepo's run command in watch mode #8517

Closed
gmanninglive opened this issue Jun 4, 2022 · 5 comments · Fixed by #8523
Closed
Assignees

Comments

@gmanninglive
Copy link

What version of Tailwind CSS are you using?

v3.0.24

What build tool (or framework if it abstracts the build tool) are you using?

Turborepo turbo run with tailwindcss cli

What version of Node.js are you using?

v16.15.1

What browser are you using?

N/A

What operating system are you using?

macOS

Reproduction URL

Describe your issue

Tailwind cli in watch mode exits early when run by turbo run. This makes it unusable in turborepo projects.

I've tracked it down to the event listeners on stdin

Because turbo repo doesn't pipe through stdin, we get an end event back when calling process.stdin.resume()

I've added a potential solution in a PR on my fork here

I'm not completely sure you would consider it your issue, but I think there is merit in this flag being useful.

Issue #1026 on Turborepo

@gmanninglive gmanninglive changed the title Cli exits process instantly when called by turborepo's run command Cli exits process instantly when called by turborepo's run command in watch mode Jun 4, 2022
@adamwathan
Copy link
Member

Thanks for flagging this and for doing the detective work to figure out the underlying cause! I haven't used Turborepo and don't know a ton about how all these things interact with each other but I saw this related issue on esbuild where it was solved without any additional flags for their use case:

evanw/esbuild#1449 (comment)

Do you think something like this could work here as well or is this situation different?

@gmanninglive
Copy link
Author

No worries, I'm happy to help.

Yes that looks like an elegant solution. I've just checked locally and it works nicely! Hopefully this would still match @josevalim use case?

And just to have a bit of context on how turborepo handles process management. It watches for system signals and pass them on. I believe it also closes all processes when one child process has non-zero exit, unless the --continue flag is set.

@thecrypticace
Copy link
Contributor

Wow that fix from esbuild really is super elegant! Ctrl-D, Ctrl-C, and Ctrl-Z all still work as expected in a terminal but launching without stdin works too. That's pretty cool. I've just merged in the fix for this which should hit our insiders build in a few minutes.

Thanks for the investigation it was super helpful! 🎉

@gmanninglive
Copy link
Author

Great thanks for getting this sorted so quickly!

@thecrypticace
Copy link
Contributor

We've run into some issues with this fix unfortunately and have reverted it for our next tagged release. What's happening is that the CLI process is left running if the thing that launched it is unable to send a signal to the process. This can happen because either the parent process has crashed or because the runtime doesn't have the ability to send signals (Erlang is an example of this).

However, it appears that Turborepo updated their Tailwind CSS example to use the concurrently npm package which happens to sidestep this problem entirely. This is because concurrently both doesn't need stdin by default and handles it correctly for child processes. I would suggest updating your scripts to run the CLI using concurrently to ensure the CLI keeps working with the upcoming releases:

{
  "scripts": {
    "watch": "concurrently \"tailwindcss -i ./src/styles.css -o ./dist/styles.css --watch\""
  }
}

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 a pull request may close this issue.

3 participants