File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ export type FlagConfigurationRequestParameters = {
108
108
pollAfterSuccessfulInitialization ?: boolean ;
109
109
pollAfterFailedInitialization ?: boolean ;
110
110
throwOnFailedInitialization ?: boolean ;
111
+ skipInitialPoll ?: boolean ;
111
112
} ;
112
113
113
114
export default class EppoClient implements IEppoClient {
@@ -181,6 +182,7 @@ export default class EppoClient implements IEppoClient {
181
182
this . configurationRequestParameters . pollAfterFailedInitialization ?? false ,
182
183
errorOnFailedStart :
183
184
this . configurationRequestParameters . throwOnFailedInitialization ?? false ,
185
+ skipInitialPoll : this . configurationRequestParameters . skipInitialPoll ?? false ,
184
186
} ,
185
187
) ;
186
188
Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ describe('poller', () => {
22
22
} ) ;
23
23
24
24
describe ( 'initial startup' , ( ) => {
25
+ it ( 'skips initial poll if configured to do so' , async ( ) => {
26
+ const poller = initPoller ( testIntervalMs , noOpCallback , { skipInitialPoll : true } ) ;
27
+ await poller . start ( ) ;
28
+ td . verify ( noOpCallback ( ) , { times : 0 } ) ;
29
+ } ) ;
30
+
25
31
it ( 'retries startup poll within same promise' , async ( ) => {
26
32
const pollerRetries = 3 ;
27
33
let callCount = 0 ;
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export default function initPoller(
23
23
pollAfterSuccessfulStart ?: boolean ;
24
24
errorOnFailedStart ?: boolean ;
25
25
pollAfterFailedStart ?: boolean ;
26
+ skipInitialPoll ?: boolean ;
26
27
} ,
27
28
) : IPoller {
28
29
let stopped = false ;
@@ -34,8 +35,9 @@ export default function initPoller(
34
35
const start = async ( ) => {
35
36
stopped = false ;
36
37
let startRequestSuccess = false ;
37
- let startAttemptsRemaining =
38
- 1 + ( options ?. maxStartRetries ?? DEFAULT_INITIAL_CONFIG_REQUEST_RETRIES ) ;
38
+ let startAttemptsRemaining = options ?. skipInitialPoll
39
+ ? 0
40
+ : 1 + ( options ?. maxStartRetries ?? DEFAULT_INITIAL_CONFIG_REQUEST_RETRIES ) ;
39
41
40
42
let startErrorToThrow = null ;
41
43
You can’t perform that action at this time.
0 commit comments