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

fix: do not end server process in CI #3659

Merged
merged 1 commit into from
Jun 24, 2021
Merged

Conversation

IanVS
Copy link
Contributor

@IanVS IanVS commented Jun 3, 2021

Description

This fixes a problem running the vite server in docker and github actions (ci) as documented in material-svelte/vite-web-test-runner-plugin#6. It took me a long time to figure out why my tests were completing just fine locally but exiting early with a 0 exit code in CI without running any tests. I eventually traced it down to the process.exit(0) added in #1857.

With the changes here, I am able to run tests successfully both locally, as well as in CI.

I would love if @nullpilot, @jonathanstiansen, and @1player could take a look and try this out to see if it meets their needs as well.

Additional context

Docker (and by extension github ci) do not always run as an interactive tty. Create-react-app had an issue when they tried to add a shutdown based on detecting an interactive terminal, and addressed it by only checking for a CI environment variable instead (see facebook/create-react-app#8845 and the referenced issue, facebook/create-react-app#8688).

As an aside, note that webpack-dev-server listens to both SIGINT and SIGTERM for docker support (webpack/webpack-dev-server#787), but SIGINT was factored out of vite and I'm not quite sure why based on the commit.

I'm also not sure how to write a test for this particular feature, but I did check that the server is still torn down when I run vite locally and then kill it with ctrl+c. I think it will also be interesting to see if CI completes successfully, since that was a problem the last time that process.stdin.resume() was added, which I've added here to match CRA and to allow the stream to drain correctly.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@IanVS
Copy link
Contributor Author

IanVS commented Jun 23, 2021

Hi, does anyone have any thoughts on this? I'm using patch-package to apply this change in my own project, and it's working well, but it would be nice to avoid that.

@bmz1
Copy link

bmz1 commented Jun 23, 2021

It would be great to run tests on CI with vite, and this is a huge blocker. I'm waiting for this as well.

@antfu antfu added the p3-minor-bug An edge case that only affects very specific usage (priority) label Jun 24, 2021
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

@nullpilot this is going to affect Elixir Phoenix dev watcher if I understand correctly, but even with the fix in #1857 there were people still having issues. The issue with docker seems more important to fix. Further PRs improving this are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants