-
-
Notifications
You must be signed in to change notification settings - Fork 187
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(kill): should not try to open a connection to a not running ReplSet #811
Conversation
Codecov Report
@@ Coverage Diff @@
## master #811 +/- ##
==========================================
+ Coverage 90.94% 91.14% +0.20%
==========================================
Files 15 15
Lines 1965 1965
Branches 494 494
==========================================
+ Hits 1787 1791 +4
+ Misses 169 165 -4
Partials 9 9
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Looks good, though we should probably also add some options to the connection (like connectTimeoutMS
which defaults to 30s)
🎉 This PR is included in version 9.0.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
hey @hasezoey. // 1)
con = await MongoClient.connect(uriTemplate(ip, port, 'admin'), {
...this.extraConnectionOptions,
directConnection: true,
socketTimeoutMS: 100,
connectTimeoutMS: 100,
waitQueueTimeoutMS: 100,
});
// 2)
con = await MongoClient.connect(uriTemplate(ip, port, 'admin'), {
...this.extraConnectionOptions,
directConnection: true,
serverSelectionTimeoutMS: 100,
}); Only the 2) case works. Right now I cannot think out of my head a test case for this alternative solution. |
Testing some cases, it is possible that the server is killed between the isAlive assert and the connection. I agree that it's better to use the connection options. I'll send another PR. |
no need to replace the change from the current PR, the options are only meant because it should not have much latency because it will always connect to localhost and so 30 second timeout is somewhat high |
I've a situation where I listen to kill signals and execute
.stop()
when needed. The replica set has already been killed because theCtrl + C
signal is propagated to the whole process group, then I waits forever to connect and send a graceful shutdown.