Hi,
Using node driver 3.3.3, there is an issue NODE-2234 where isConnected will always return true if the connection option useUnifiedTopology: true is set. As of node driver 3.3.3, this issue is still ongoing.
However there are things I noticed in the code you posted:
useUnifiedTopology in your options. This means that you’re not going to see the effect of NODE-2234, thus isConnected should return false when the MongoDB instance was killed (even with kill -9). I have confirmed that this is the case by running a simplified version of the code you posted.setTimeout. This would make isConnected return false since the connection was already closed when the timer is started. I also have confirmed this is to be the case.So I’m not sure how you can see isConnected to return true in both cases. Could you confirm:
useUnifiedTopology in your actual code so we can rule out NODE-2234?setTimeout a deliberate decision?Best regards,
Kevin