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

Ensure --watch mode exits correctly when stdin is closed. #3493

Merged
merged 2 commits into from
Apr 12, 2020

Conversation

jakesgordon
Copy link
Contributor

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

This PR ensures that the rollup --watch process exits correctly when stdin is closed by the parent process.

This is necessary when rollup is used as the front end for an Elixir Phoenix application. In dev mode, the phoenix watchers run the rollup command as a child process and the underlying erlang port mechanism assumes that the child process closes when the parent stdin is closed. Without this fix the old zombie processes never close and accumulate as you stop and start in development mode.

This was discussed and fixed in 2017 in the original rollup-watcher repository:

It appears to then have been removed as a side effect of another change

Finally, was requested back in a PR that never got merged because of some doubt around the need to hide it behind a CLI flag

For reference, webpack implements this hidden behind the --watch-stdin CLI flag.

jakesgordon and others added 2 commits April 10, 2020 14:03
This is necessary when rollup is used as the front end for an Elixir
Phoenix application. In dev mode, the phoenix watchers run the rollup
command as a child process and the underlying erlang port mechanism
assumes that the child process closes when the parent stdin is
closed. Without this fix the old zombie processes never close and
accumulate as you stop and start in development mode.

This was discussed and fixed in 2017 in the original rollup-watcher
repository:

  * rollup/rollup-watch#30 (comment)
  * https://github.com/rollup/rollup-watch/pull/57/files

It appears to then have been removed as a side effect of another change

  * rollup#2410

Finally, was requested back in a PR that never got merged because of
some doubt around the need to hide it behind a CLI flag

  * https://github.com/rollup/rollup/pull/2653/files

For reference, webpack implements this hidden behind the --watch-stdin
CLI flag.
@codecov
Copy link

codecov bot commented Apr 12, 2020

Codecov Report

Merging #3493 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3493   +/-   ##
=======================================
  Coverage   96.08%   96.08%           
=======================================
  Files         175      175           
  Lines        5955     5956    +1     
  Branches     1752     1752           
=======================================
+ Hits         5722     5723    +1     
  Misses        118      118           
  Partials      115      115           
Impacted Files Coverage Δ
cli/run/watch.ts 86.30% <100.00%> (+0.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b463308...56436d8. Read the comment docs.

Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

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

Finally managed to add a test that is actually red (or rather timing out) without your change. Thanks for pushing this, will release it in a moment.

@lukastaegert lukastaegert merged commit 57bb54e into rollup:master Apr 12, 2020
@jakesgordon
Copy link
Contributor Author

Thank you for adding the test! Great work, much appreciated.

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 this pull request may close these issues.

None yet

2 participants