-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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: Always close the reporter before exiting #4283
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, although the linter has a problem with your call to unref
.
I don't want to block this without a test, but if it's easy to add a unit test or something, that would be preferable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as well as long as the builds pass.
Do you think we can add a smoke test for this?
Hm Flow seems to recognize Re: tests, if you think it's better I'll add one. |
If it is not too much trouble, a test would be great. If not, well... 🤷♂️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM but I think AppVeyor failures are legit and need to be fixed before merging.
@@ -152,6 +152,8 @@ export default class BaseReporter { | |||
this.peakMemoryInterval = setInterval(() => { | |||
this.checkPeakMemory(); | |||
}, 1000); | |||
// $FlowFixMe: Node's setInterval returns a Timeout, not a Number | |||
this.peakMemoryInterval.unref(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 👍 with this change but curious why clearInterval(this.peakMemoryInterval);
in close()
below isn't enough.
src/cli/index.js
Outdated
@@ -349,10 +349,10 @@ export function main({ | |||
return errorReportLoc; | |||
} | |||
|
|||
const exit = exitCode => { | |||
function exit(exitCode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why convert to "normal" functions from arrow functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because otherwise exit
is undefined at lines 178 & 195, since the assignment hasn't been executed yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, let's move this above then? Or add a comment if moving up is not possible?
5276535
to
58f5d09
Compare
58f5d09
to
31925a0
Compare
I don't think it fixes #4276, although this is a welcome PR. |
**Summary** A combination of changes have caused `yarn upgrade-interactive` to exit with a promise rejection. In short, I believe it has always been a problem, but #3995 exposed it to the prompt. The child rejection inside of [upgrade-interactive](https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/upgrade-interactive.js#L152) is fine, as it was handled by the `Promise.race` condition; however, rejecting at the parent level inside of [console-reporter](https://github.com/yarnpkg/yarn/blob/master/src/reporters/console/console-reporter.js#L458) causes[ loud-rejection](https://github.com/sindresorhus/loud-rejection) to handle this. I believe @arcanis 's PR #4283 is what would allow us not to hook into `SIGINT` inside of the console reporter and allow the reporter to cleanly close itself. **Test Plan** Will work on some scenarios! This PR needs some more verification on my end ... @BYK @torifat @arcanis please jump in and provide any feedback you think could be helpful! Opened early for visibility :)
* Prevents the memory controls from hanging the process * Update base-reporter.js * Adds a test
**Summary** A combination of changes have caused `yarn upgrade-interactive` to exit with a promise rejection. In short, I believe it has always been a problem, but yarnpkg#3995 exposed it to the prompt. The child rejection inside of [upgrade-interactive](https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/upgrade-interactive.js#L152) is fine, as it was handled by the `Promise.race` condition; however, rejecting at the parent level inside of [console-reporter](https://github.com/yarnpkg/yarn/blob/master/src/reporters/console/console-reporter.js#L458) causes[ loud-rejection](https://github.com/sindresorhus/loud-rejection) to handle this. I believe @arcanis 's PR yarnpkg#4283 is what would allow us not to hook into `SIGINT` inside of the console reporter and allow the reporter to cleanly close itself. **Test Plan** Will work on some scenarios! This PR needs some more verification on my end ... @BYK @torifat @arcanis please jump in and provide any feedback you think could be helpful! Opened early for visibility :)
Summary
Fix #4276
In some particular cases, the reporters are not correctly closed before Yarn exits. It makes the process hang, because the reporters are expected to periodically check for the RAM usage. This patch does two things:
unref
, so that it will never prevent the process from exiting.Test plan
I don't think tests are required for this fix, since the reproduction steps are fairly narrow (the bug only occurred when using Yarn in an invalid way) and won't allow us to catch any other bug than this one.