-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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 for issue #2713 #2714
Fix for issue #2713 #2714
Conversation
* Eagerly set the process exitcode in case the write callback isn't executed before the process terminates. * Remove the extraneous call to `done()` at the bottom of the function. * Cleanup the `draining` reduction and value check in `done` into separate lines for easier reading.
Is is possible to consistently recreate the issue from #2713 ? If it is, a test case to guard against regresssions would be helpful |
I wasn't able to create a standalone test case. Seems timing dependent in node. |
Ping for action? |
Can we get this PR approved or follow up with review comments? |
Ping-a-ling-a-ping-ping |
@Munter Sorry for the direct ping. Mind taking another look? |
I understand the value of eagerly setting the exitCode with Without tests I'm not sure what the bigger consequences are of removing the |
@Munter What's your concern about the An alternative to my approach for making the system balanced is to initialize |
@Munter waiting for your response. |
@Munter ping for response. |
Why not just address the setting of (Actually, we should double-check whether the draining logic's |
@ScottFreeCode That sounds reasonable. I'll send out a new PR shortly. |
Simpler version of PR mochajs#2714 which only eagerly sets the exitcode without playing with the draining semantics
To workaround process being terminated earlier than expected. Simpler version of PR #2714 which only eagerly sets the exitcode without playing with the draining semantics.
@ScottFreeCode can you elaborate? The logic rewrite looks good to me. Regarding that extraneous if (!(draining--)) { The condition will be true when the value of So the logic was correct. But laid out in a very confusing way. |
Thanks, that's what I remember discussing (or at least looking at) before... The parentheses make it particularly confusing because normally they're used to force things to happen in a certain order, but in this case we've got a rare instance of C/C++-style variable-value separation that leaked into JS and even the parentheses don't affect that. (I guess they ensure that the decrement is applied to the variable and not to the result of the negation?) So it's equivalent to: if (!drain) {
...exit...
}
drain -= 1 ...and not to: drain -= 1
if (!drain) {
...exit...
} And so we don't need to change it for correctness... But we really ought to change it for clarity. In fact, I would love to see an ESLint rule against postincrement/postdecrement operators. (Wouldn't even say no to such a rule against preincrement/predecrement as well, considering command-query separation ought to be respected if you're going to be using mutable variables in the first place...) |
This was fixed via #2820 |
To workaround process being terminated earlier than expected. Simpler version of PR mochajs#2714 which only eagerly sets the exitcode without playing with the draining semantics.
done()
at the bottom of the function.draining
reduction and value check indone
into separate lines for easier reading.