-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
add failing test demonstrating long running onExit() hook in child process #135
Conversation
bf65e22
to
20d109b
Compare
20d109b
to
5c17496
Compare
I assume this is safe to close since #136 is in master? |
I would prefer to see it merged. |
despite the branch name, it does not actually fix anything (you beat me to the punch on that). it's just a test |
I think this test is kind of complicating it, since we already have a test for this. What situation does this test checks? |
Just not understanding the purpose completely. Could you please explain? |
So, The existing test covers making sure we force close some process that is being kept open due to a perpetual process (i.e. That's the The other scenario is when we send a kill signal to the process, and it intentionally intercepts and delays closure of the process. This is the case with I run through a 2 second loop var start = Date.now()
while (Date.now() - start > 2000) {} // just waiting 2 seconds synchronously because I have to be synchronous inside onExit
process.send({..delay-completed-event...}) Before all our changes we were exiting the parent and killing the child before the I agree, it's not a super straightforward test, but I am simulating a rather convoluted process and I don't know how to make it simpler. |
|
||
fork(fixture('long-running.js')) | ||
.on('exit', function () { | ||
t.ok(Date.now() - start < 10000); | ||
t.ok(Date.now() - start < 10000, 'did NOT wait for setTimeout(fn, 15000'); | ||
t.ok(cleanupCompleted, 'did wait for onExit(fn) to complete'); |
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.
these assertion messages are bad. I should fix them
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.
Those are error messages, they are displayed when assertion fails.
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.
Haha, race condition :D
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.
right - I've got them in the affirmative ('did NOT wait for setTimeout(fn, 15000')'
) -that is actually what we want (do not wait 15 seconds).
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.
@jamestalmage I've added Windows testing with AppVeyor and this assertion fails: https://ci.appveyor.com/project/sindresorhus/ava/build/2/job/w7efao2if7n2g2q9 Could you take a look?
Ok, let's see what @sindresorhus thinks. |
👍 |
RE: #134