Skip to content

Commit 88d87dd

Browse files
authored
fix(event processor): Treat eventFlushInterval 0 as invalid (#351)
Summary: When 0 is provided for eventFlushInterval, it should be ignored and the default used instead. Test plan: New unit test
1 parent 1be4665 commit 88d87dd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function validateEventBatchSize(eventBatchSize) {
3131
* @returns boolean
3232
*/
3333
function validateEventFlushInterval(eventFlushInterval) {
34-
return fns.isFinite(eventFlushInterval) && eventFlushInterval >= 0;
34+
return fns.isFinite(eventFlushInterval) && eventFlushInterval > 0;
3535
}
3636

3737
module.exports = {

packages/optimizely-sdk/lib/utils/event_processor_config_validator/index.tests.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ describe('utils/event_processor_config_validator', function() {
3838
assert.isFalse(eventProcessorConfigValidator.validateEventFlushInterval(-1000));
3939
});
4040

41+
it('returns false for 0', function() {
42+
assert.isFalse(eventProcessorConfigValidator.validateEventFlushInterval(0));
43+
});
44+
4145
it('returns true for a positive integer', function() {
4246
assert.isTrue(eventProcessorConfigValidator.validateEventFlushInterval(30000));
4347
});

0 commit comments

Comments
 (0)