-
Notifications
You must be signed in to change notification settings - Fork 30.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
refactor test-http-exceptions
file to use countdown
#17199
Closed
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fb56205
Fixes: https://github.com/nodejs/node/issues/17169 (test-http-excepti…
Bamieh 85adb63
mustCall inside countdown
Bamieh 3610dd3
Add test case for countdown
Bamieh 0d31fc3
Update countdown docs to hint the change
Bamieh 079d736
Update README.md
Bamieh d624399
Update README.md
Bamieh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This should be wrapped in
common.mustCall
, also should the listener ofprocess.on('uncaughtException')
andserver.listen
This kind of reminds me: should we wrap the cb in
common.mustCall
in the countdown module by default? @jasnellThere 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.
Yeah, I've been thinking the same thing. It would be worthwhile I think
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.
Come to think of it, maybe this test does not need the countdown module and can just wrap the
process.on('uncaughtException')
listener incommon.mustCall(..., NUMBER_OF_EXCEPTIONS)
, because every expected action is the same. The countdown module seems to be more suitable for actions that vary.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.
@joyeecheung unless i am overlooking something; I didn't wrap it in a
mustCall
since not invoking the callback will result in a timeout and hence a failure in the test anyways, but adding it does not hurt as 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.
If you do go with this (and I'm with @joyeecheung that this maybe doesn't need
Countdown
): Can you please wrapprocess.exit(0)
in{
and}
?Without
{
and}
, then the result ofprocess.exit(0)
is the return value of the function. That function shouldn't have a return value.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.
@Trott
process.exit()
terminates the process synchronously, so the return value will not get passed back from the invocation, so it does not really matter if you pass an explicit return or not. I'll do it anyways for convention.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.
Regarding wrapping the countdown with a mustCall, i think its a good idea to decide soon before contributors start implementing more refactors
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 think in general, use
common.mustCall
if the code callingcountdown.dec()
is always the same, and usecountdown
if the caller would be different. That way the code is cleaner. If we are trying to make the code cleaner by usingcountdown
, then I see no reason not to make it even cleaner withcommon.mustCall
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.
Also...can we implement
common.mustCall
on top ofcountdown
?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.
@joyeecheung i have implemented
mustCall
on top of countdown, but im not sure i fully understand your suggestion about replacingcountdown
withmustCall
however how are we going to tell the code to
process.exit(0)
? i cant see that happening without a counter