nodejs-driver
nodejs-driver copied to clipboard
Cancel scheduled ControlConnection refresh if shutdown was called
Store timeout, used to schedule refresh call, and clear it on shutdown.
Even though refresh call has check if shutdown was called, timeout itself may prevent nodejs process from shutting down until timeout is reached.
I have some concerns about test itself. Not sure that all the setup steps are required. But I've copied it mostly from previous test "should reconnect when all hosts go down and back up". What I wanted from the test:
- spin up cluster
- open control connection and ensure that it is live
- stop cluster
- call control connection shutdown
- verify that refresh was not called
So the main test is pasted below, the rest is a boilerplate copied from other test.
// start spying on _refresh calls
cc._refresh = sinon.spy(cc._refresh);
cc.shutdown();
// wait for reconnectionDelay with 10% lag
await helper.delayAsync(parseInt(reconnectionDelay * 1.1, 10));
assert.ok(cc._refresh.notCalled);