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 recursive process.exit calls #5445

Merged
merged 1 commit into from
Feb 2, 2018
Merged

Fix recursive process.exit calls #5445

merged 1 commit into from
Feb 2, 2018

Conversation

mjesun
Copy link
Contributor

@mjesun mjesun commented Feb 2, 2018

Use process.exitCode instead of recursively calling process.exit() on a exit event.

Fixes #5332. The reason why it stopped working when merged #5313 is because on every single call to process.exit(), the process.exitCode is checked just before exiting. However the exit module implementation does not do that, so the code was never set.

In turn, looking at the process.exit implementation, it is clear that calling process.exit() from an exit event will have no effect but changing the exit code. Thus we can safely remove the second exit() call and only modify the exit code, so that the native method picks it. A bit confusing, I know.

@mjesun
Copy link
Contributor Author

mjesun commented Feb 2, 2018

I have no idea on how can this break packages/expect/src/__tests__/stacktrace.test.js.

@cpojer cpojer merged commit 4ceed46 into jestjs:master Feb 2, 2018
@@ -11,7 +11,6 @@ import type {Argv} from 'types/Argv';
import type {EnvironmentClass} from 'types/Environment';

import chalk from 'chalk';
import exit from 'exit';
Copy link
Member

@SimenB SimenB Feb 3, 2018

Choose a reason for hiding this comment

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

should it be removed from dependencies as well? Some quick grepping says yes

@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The cli doesn't exit correctly when stdout is a non-tty
4 participants