File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
libs/providers/go-feature-flag/src/lib/evaluator Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -69,14 +69,24 @@ export class InProcessEvaluator implements IEvaluator {
6969 await this . loadConfiguration ( true ) ;
7070 // Start periodic configuration polling
7171 if ( this . options . flagChangePollingIntervalMs && this . options . flagChangePollingIntervalMs > 0 ) {
72- this . periodicRunner = setInterval (
73- ( ) =>
74- this . loadConfiguration ( false ) . catch ( ( error ) => this . logger ?. error ( 'Failed to load configuration:' , error ) ) ,
75- this . options . flagChangePollingIntervalMs ,
76- ) ;
72+ this . periodicRunner = setTimeout ( ( ) => this . poll ( ) , this . options . flagChangePollingIntervalMs ) ;
7773 }
7874 }
7975
76+ /**
77+ * Poll the configuration from the API.
78+ */
79+ private poll ( ) : void {
80+ this . loadConfiguration ( false )
81+ . catch ( ( error ) => this . logger ?. error ( 'Failed to load configuration:' , error ) )
82+ . finally ( ( ) => {
83+ if ( this . periodicRunner ) {
84+ // check if polling is still active
85+ this . periodicRunner = setTimeout ( ( ) => this . poll ( ) , this . options . flagChangePollingIntervalMs ) ;
86+ }
87+ } ) ;
88+ }
89+
8090 /**
8191 * Evaluates a boolean flag.
8292 * @param flagKey - The key of the flag to evaluate.
You can’t perform that action at this time.
0 commit comments