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: keep stdin unpaused after ora completes #2904

Merged
merged 3 commits into from
Jul 11, 2022
Merged

Conversation

clavin
Copy link
Member

@clavin clavin commented Jul 7, 2022

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • The changes are appropriately documented (if applicable).
  • The changes have sufficient test coverage (if applicable).
  • The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:

As a side-effect of using node:readline, when ora completes it may pause stdin. Once it is in this paused state, it is impossible to truly revert to the original "unpaused" state as calling resume on stdin has its own side-effect of keeping the node process alive as long as stdin remains unpaused (which is different than the default, where stdin is both unpaused but will not keep the process alive).

To get around this, I added a flag on asyncOra that will maintain stdin's unpaused state across ora's completion, but only for cases where that behavior is desirable, like the electron-forge start which both reads from stdin and is meant to stay alive "forever".

Fixes #2319.

@clavin clavin requested a review from malept July 7, 2022 17:56
@malept
Copy link
Member

malept commented Jul 7, 2022

Have you tested this with both Webpack and non-Webpack templates?

@codecov
Copy link

codecov bot commented Jul 7, 2022

Codecov Report

Merging #2904 (2265971) into master (345250c) will decrease coverage by 0.12%.
The diff coverage is 22.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2904      +/-   ##
==========================================
- Coverage   71.82%   71.69%   -0.13%     
==========================================
  Files          79       79              
  Lines        2385     2392       +7     
  Branches      449      450       +1     
==========================================
+ Hits         1713     1715       +2     
- Misses        450      454       +4     
- Partials      222      223       +1     
Impacted Files Coverage Δ
packages/api/core/src/api/start.ts 64.04% <16.66%> (-1.84%) ⬇️
packages/utils/async-ora/src/ora-handler.ts 81.81% <33.33%> (-4.85%) ⬇️

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 345250c...2265971. Read the comment docs.

@clavin
Copy link
Member Author

clavin commented Jul 7, 2022

I have certainly tested this with the webpack template, will test with a non-webpack one too rn just to be safe!

@clavin
Copy link
Member Author

clavin commented Jul 7, 2022

It is restarting the server in both cases 👍 I tested on the webpack template, once with and once without the plugin enabled in the config.

Copy link
Member

@malept malept left a comment

Choose a reason for hiding this comment

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

Minor suggestion but otherwise :shipit:

packages/api/core/src/api/start.ts Show resolved Hide resolved
@clavin clavin merged commit aad9c7e into master Jul 11, 2022
@clavin clavin deleted the clavin/async-ora-fix branch July 11, 2022 15:06
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.

Typing rs in the terminal does not restart the dev environment app
2 participants