Skip to content

Commit

Permalink
fix(srv-poller): always provide a valid number for intervalMS
Browse files Browse the repository at this point in the history
A typo in the getter for `intervalMS` caused polling to occur
immediately because a value of `undefined` was returned.

NODE-2375
  • Loading branch information
mbroadst committed Dec 6, 2019
1 parent 8da416f commit afb125f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/core/sdam/srv_polling.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SrvPoller extends EventEmitter {
}

get intervalMS() {
return this.haMode ? this.heartbeatFrequencyMS : this.rescanSrvIntervalMs;
return this.haMode ? this.heartbeatFrequencyMS : this.rescanSrvIntervalMS;
}

start() {
Expand Down
7 changes: 7 additions & 0 deletions test/unit/sdam/srv_polling.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ describe('Mongos SRV Polling', function() {
context.sinon.stub(poller, 'parentDomainMismatch');
}

it('should always return a valid value for `intervalMS`', function() {
const poller = new SrvPoller({ srvHost: SRV_HOST });
expect(poller)
.property('intervalMS')
.to.equal(60000);
});

describe('success', function() {
it('should emit event, disable haMode, and schedule another poll', function(done) {
const records = [srvRecord('jalad.tanagra.com'), srvRecord('thebeast.tanagra.com')];
Expand Down

0 comments on commit afb125f

Please sign in to comment.