-
Notifications
You must be signed in to change notification settings - Fork 53
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(attach): improve disconnect test #414
Conversation
nvim.quit(); | ||
|
||
proc.on('close', () => { | ||
expect(disconnectMock.mock.calls.length).toBe(1); | ||
expect(disconnectCalled).toBe(true); | ||
done(); |
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.
since the test is timing out, that means this done
is not called, which means the 'close' event isn't emitted (or stuff is getting disposed before handling the emitted 'close' event).
This proc.on was added in c9a3dd0 for some reason. But later the proc.kill
call was removed, so whatever reason that proc.on
was added no longer exists.
we should just restore the old logic, which simply did nvim.on('disconnect', done);
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.
Yeah, I understand that, but how race could happen to cause this problem?
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.
Do we still need the disconnect call on proc ?
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.
oh, that causes the test harness (jest) to kill Nvim too early, which then raises EPIPE because Nvim still has messages to process.
Oops, failed again, so the mock function indeed not the issue here. |
nvim.on('disconnect', () => { | ||
called = true; | ||
}); | ||
|
||
nvim.quit(); | ||
|
||
proc.on('close', () => { |
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.
Based on local runs, changing this to 'exit' seems more reliable. It's strange that 'close' is sometimes not emitted, but that was never the purpose of this test...
proc.on('close', () => { | |
proc.on('exit', () => { |
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.
Make sense, we only want make sure disconnect is called.
We can run CI a few more times to see if it's working. |
Looks like it happens on windows. see nodejs/node#4500 |
CI has been green 10+ times 🎉
#314 happens on all platforms. Based on some local testing, it looks like |
@justinmk Thanks for your guide! |
Closes #314.
Problem:
This test may time out, because the
proc.on('close')
event is never triggered.Solution:
Listen for 'exit' instead of 'close'. This may indicate that Nvim or node-client
is not properly closing all of its streams, but that is unrelated to this
particular test.