1- import { ISettings } from '../../../../ types/splitio ' ;
1+ import { ISettings } from '../../../types' ;
22import { ISplitChangesResponse } from '../../../dtos/types' ;
33import { IFetchSplitChanges , IResponse } from '../../../services/types' ;
44import { IStorageBase } from '../../../storages/types' ;
55import { FLAG_SPEC_VERSION } from '../../../utils/constants' ;
66import { base } from '../../../utils/settingsValidation' ;
77import { ISplitChangesFetcher } from './types' ;
8+ import { LOG_PREFIX_SYNC_SPLITS } from '../../../logger/constants' ;
89
910const PROXY_CHECK_INTERVAL_MILLIS_CS = 60 * 60 * 1000 ; // 1 hour in Client Side
1011const PROXY_CHECK_INTERVAL_MILLIS_SS = 24 * PROXY_CHECK_INTERVAL_MILLIS_CS ; // 24 hours in Server Side
@@ -20,6 +21,7 @@ function sdkEndpointOverriden(settings: ISettings) {
2021// @TODO breaking: drop support for Split Proxy below v5.10.0 and simplify the implementation
2122export function splitChangesFetcherFactory ( fetchSplitChanges : IFetchSplitChanges , settings : ISettings , storage : Pick < IStorageBase , 'splits' | 'rbSegments' > ) : ISplitChangesFetcher {
2223
24+ const log = settings . log ;
2325 const PROXY_CHECK_INTERVAL_MILLIS = settings . core . key !== undefined ? PROXY_CHECK_INTERVAL_MILLIS_CS : PROXY_CHECK_INTERVAL_MILLIS_SS ;
2426 let lastProxyCheckTimestamp : number | undefined ;
2527
@@ -41,6 +43,7 @@ export function splitChangesFetcherFactory(fetchSplitChanges: IFetchSplitChanges
4143 // Handle proxy error with spec 1.3
4244 . catch ( ( err ) => {
4345 if ( err . statusCode === 400 && sdkEndpointOverriden ( settings ) && settings . sync . flagSpecVersion === FLAG_SPEC_VERSION ) {
46+ log . error ( LOG_PREFIX_SYNC_SPLITS + 'Proxy error detected. If you are using Split Proxy, please upgrade to latest version' ) ;
4447 lastProxyCheckTimestamp = Date . now ( ) ;
4548 settings . sync . flagSpecVersion = '1.2' ; // fallback to 1.2 spec
4649 return fetchSplitChanges ( since , noCache , till ) ; // retry request without rbSince
@@ -66,6 +69,7 @@ export function splitChangesFetcherFactory(fetchSplitChanges: IFetchSplitChanges
6669
6770 // Proxy recovery
6871 if ( lastProxyCheckTimestamp ) {
72+ log . info ( LOG_PREFIX_SYNC_SPLITS + 'Proxy error recovered' ) ;
6973 lastProxyCheckTimestamp = undefined ;
7074 return Promise . all ( [ storage . splits . clear ( ) , storage . rbSegments . clear ( ) ] )
7175 . then ( ( ) => splitChangesFetcher ( storage . splits . getChangeNumber ( ) as number , undefined , undefined , storage . rbSegments . getChangeNumber ( ) as number ) ) ;
0 commit comments