File tree Expand file tree Collapse file tree 4 files changed +36
-3
lines changed Expand file tree Collapse file tree 4 files changed +36
-3
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @eppo/node-server-sdk" ,
3
- "version" : " 3.11 .0" ,
3
+ "version" : " 3.12 .0" ,
4
4
"description" : " Eppo node server SDK" ,
5
5
"main" : " dist/index.js" ,
6
6
"files" : [
Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ export interface IClientConfig {
43
43
/** Poll for new configurations even if the initial configuration request failed. (default: false) */
44
44
pollAfterFailedInitialization ?: boolean ;
45
45
46
+ /**
47
+ * Poll for new configurations (every `pollingIntervalMs`) after successfully requesting the initial configuration. (default: true)
48
+ * For server-side applications, this defaults to true to ensure configurations stay up-to-date for the life of the process.
49
+ */
50
+ pollAfterSuccessfulInitialization ?: boolean ;
51
+
46
52
/** Amount of time in milliseconds to wait between API calls to refresh configuration data. Default of 30_000 (30s). */
47
53
pollingIntervalMs ?: number ;
48
54
Original file line number Diff line number Diff line change @@ -708,4 +708,31 @@ describe('EppoClient E2E test', () => {
708
708
} ) ;
709
709
} ) ;
710
710
} ) ;
711
+
712
+ describe ( 'pollAfterSuccessfulInitialization' , ( ) => {
713
+ it ( 'should default to true when not specified' , async ( ) => {
714
+ const client = await init ( {
715
+ apiKey,
716
+ baseUrl : `http://127.0.0.1:${ TEST_SERVER_PORT } ` ,
717
+ assignmentLogger : mockLogger ,
718
+ } ) ;
719
+
720
+ // Access the internal configurationRequestParameters to verify the default
721
+ const configurationRequestParameters = client [ 'configurationRequestParameters' ] ;
722
+ expect ( configurationRequestParameters . pollAfterSuccessfulInitialization ) . toBe ( true ) ;
723
+ } ) ;
724
+
725
+ it ( 'should use the provided value when specified' , async ( ) => {
726
+ const client = await init ( {
727
+ apiKey,
728
+ baseUrl : `http://127.0.0.1:${ TEST_SERVER_PORT } ` ,
729
+ assignmentLogger : mockLogger ,
730
+ pollAfterSuccessfulInitialization : false ,
731
+ } ) ;
732
+
733
+ // Access the internal configurationRequestParameters to verify the custom value
734
+ const configurationRequestParameters = client [ 'configurationRequestParameters' ] ;
735
+ expect ( configurationRequestParameters . pollAfterSuccessfulInitialization ) . toBe ( false ) ;
736
+ } ) ;
737
+ } ) ;
711
738
} ) ;
Original file line number Diff line number Diff line change @@ -79,8 +79,8 @@ export async function init(config: IClientConfig): Promise<EppoClient> {
79
79
requestTimeoutMs,
80
80
numInitialRequestRetries,
81
81
numPollRequestRetries,
82
- // For server-side, we always want to keep polling for the life of the process
83
- pollAfterSuccessfulInitialization : true ,
82
+ // For server-side, we default to keep polling for the life of the process
83
+ pollAfterSuccessfulInitialization : config . pollAfterSuccessfulInitialization ?? true ,
84
84
pollAfterFailedInitialization,
85
85
pollingIntervalMs,
86
86
throwOnFailedInitialization,
You can’t perform that action at this time.
0 commit comments