-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
test: fix setTimeout, remove unused err #10193
Conversation
@@ -14,7 +15,7 @@ timeoutd.on('error', common.mustCall(function(e) { | |||
})); | |||
|
|||
timeoutd.run(function() { | |||
setTimeout(function() { | |||
setTimeout(function onTimeout() { |
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?
@@ -23,7 +23,7 @@ function test1() { | |||
*/ | |||
const d = domain.create(); | |||
d.run(function() { | |||
setTimeout(function onTimeout() { | |||
setImmediate(function onSetImmediate() { |
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.
The test used to test that exceptions thrown from setTimeout were in the domain, now they test that test thrown from setImmediate are still in the domain! I don't think you are looking at what the test is doing.
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 understand your point. Since it does not specify a duration (the second argument), I think it's more appropriate to change this call to setImmediate()
instead of setTimeout()
.
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.
For this test, instead of changing the setTimeout()
to setImmediate()
, it is better to keep setTimeout()
but add a duration of 1
. @sam-github is right. This is testing a timer, not an immediate. Changing it to an immediate changes the test. In other words, the setTimeout()
is not an incidental tool used within the test. It is part of what is actually being tested.
(In @amazingandyyy's defense, I'm the one that suggested changing setTimeout()
with no duration to setImmediate()
in the first place. But yeah, that's not right in this test.)
process.send('errorHandledByDomain'); | ||
}); | ||
|
||
d5.run(function() { | ||
d6.run(function() { | ||
setTimeout(function onTimeout() { | ||
setImmediate(function onSetImmediate() { |
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.
ditto. the point of the test isn't to run these functions, its to test interactions with timeouts and domains
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.
same here, it does not specify a duration (the second argument), setImmediate is more appropriate.
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.
@sam-github is (as usual) right on this one too. We're testing that domains and setTimeout()
interact the way they are supposed to, so it needs to be setTimeout()
. Add a duration of 1
rather than changing it to setImmediate()
.
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 looks to me like a combination of random code churn, and unintended changes to the function of the tests.
I don't think the changes to |
process.send('errorHandledByDomain'); | ||
}); | ||
|
||
d9.run(function() { | ||
d10.run(function() { | ||
setTimeout(function onTimeout() { | ||
setImmediate(function onSetImmediate() { |
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.
Same here: Use setTimeout()
with a duration of 1
instead of setImmediate()
.
Commits need to be squashed |
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
Squashing commits can also be done by whoever lands the PR, btw.
@addaleax, it can, but last time I did that @mhdawson suggested I ask the PR author. Rebasing is part of the work flow, so knowing how to do that helps get people up to speed with node work habits. On the other hand, doing it for them makes it easier. I don't care. @amazingandyyy do you want to squash, or do you want me to? |
@sam-github Right, but squashing and rebasing can be tricky depending on somebody’s git experience level, so I like to mention that it’s optional. |
@sam-github @addaleax I just do "git rebase -i HEAD~6" and then replace "pick" by "squash" then save the file. I am not sure if this works? I still see 6 commits on this PR. I appreciate this practicing chance. btw, Please feel free to squash it(if my rebasing doesn't work) when landing, thanks! |
@amarzavery the last step is to comment all the msg except one (the one that you are going to use as a commit msg) |
@amazingandyyy That sounds about right, except you’ll need to keep the first commit as |
file: test/parallel/test-domain-uncaught-exception.js 1. There are three setTimeout() in the file and they do not specify a duration (the second argument), so I change them to setImmediate() instead. 2. There are four callbacks that take an argument called `err` but that argument is never used, so I removed them.
Thank you! @italoacasas and @addaleax I leave one as pick and clean commit message, then got
but I still see 6 commits on this PR, do I miss any step or what's next step to complete(make the squashing work?) Thanks |
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
@amazingandyyy just noticed that the commit message does not fit our contributor guidelines. I'll fix up as part of landing but can you review the guidelines for the next time. The commit message should start with a prefix. In this case 'test:' and the length needs to be less than or equal to 50 chars. See https://github.com/nodejs/node/blob/master/CONTRIBUTING.md#step-3-commit |
CI failure on arm was #10073, so not related to this change so CI is good. Will land. |
@amazingandyyy one more thing for the next time as well. We need your full name in the commit. I've amended while landed but fore the next time can you make sure its set to:
|
landed as e27c2a7 |
file: test/parallel/test-domain-uncaught-exception.js 1. There are three setTimeout() in the file and they do not specify a duration (the second argument), so I change them to setImmediate() instead. 2. There are four callbacks that take an argument called `err` but that argument is never used, so I removed them. PR-URL: #10193 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
@mharsch thank you! I will follow contributor guidelines and add my full name next time! Thank you for posting reference! |
We do not need anyone's name for commits. It is up to them. |
(Always good to ask first-time contributors, though, of course! People forget to set the name all the time. So, it's a nice gesture to make sure they are making a conscious choice in the matter. I'm just reacting to the "need your full name" phrasing. If someone wants to be "Pat" or "avatar-46", that's their choice.) |
file: test/parallel/test-domain-uncaught-exception.js 1. There are three setTimeout() in the file and they do not specify a duration (the second argument), so I change them to setImmediate() instead. 2. There are four callbacks that take an argument called `err` but that argument is never used, so I removed them. PR-URL: #10193 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
file: test/parallel/test-domain-uncaught-exception.js 1. There are three setTimeout() in the file and they do not specify a duration (the second argument), so I change them to setImmediate() instead. 2. There are four callbacks that take an argument called `err` but that argument is never used, so I removed them. PR-URL: #10193 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
file: test/parallel/test-domain-uncaught-exception.js 1. There are three setTimeout() in the file and they do not specify a duration (the second argument), so I change them to setImmediate() instead. 2. There are four callbacks that take an argument called `err` but that argument is never used, so I removed them. PR-URL: #10193 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
file: test/parallel/test-domain-uncaught-exception.js 1. There are three setTimeout() in the file and they do not specify a duration (the second argument), so I change them to setImmediate() instead. 2. There are four callbacks that take an argument called `err` but that argument is never used, so I removed them. PR-URL: #10193 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
file: test/parallel/test-domain-uncaught-exception.js 1. There are three setTimeout() in the file and they do not specify a duration (the second argument), so I change them to setImmediate() instead. 2. There are four callbacks that take an argument called `err` but that argument is never used, so I removed them. PR-URL: #10193 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
file: test/parallel/test-domain-uncaught-exception.js 1. There are three setTimeout() in the file and they do not specify a duration (the second argument), so I change them to setImmediate() instead. 2. There are four callbacks that take an argument called `err` but that argument is never used, so I removed them. PR-URL: #10193 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
file: test/parallel/test-domain-uncaught-exception.js 1. There are three setTimeout() in the file and they do not specify a duration (the second argument), so I change them to setImmediate() instead. 2. There are four callbacks that take an argument called `err` but that argument is never used, so I removed them. PR-URL: #10193 Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
file: test/parallel/test-domain-uncaught-exception.js
There are three setTimeout() in the file and they do not specify a
duration (the second argument), so I change them to setImmediate()
instead.
There are four callbacks that take an argument called err but that
argument is never used, I just removed them.