@@ -59,7 +59,7 @@ import {
59
59
NODE_CLIENT_ENGINE ,
60
60
CLIENT_VERSION ,
61
61
} from '../utils/enums' ;
62
- import { Fn , Maybe , OpType , OpValue } from '../utils/type' ;
62
+ import { Fn , Maybe , OpType } from '../utils/type' ;
63
63
import { resolvablePromise } from '../utils/promise/resolvablePromise' ;
64
64
65
65
import { NOTIFICATION_TYPES , DecisionNotificationType , DECISION_NOTIFICATION_TYPES } from '../notification_center/type' ;
@@ -75,9 +75,6 @@ import {
75
75
EVENT_KEY_NOT_FOUND ,
76
76
NOT_TRACKING_USER ,
77
77
VARIABLE_REQUESTED_WITH_WRONG_TYPE ,
78
- ONREADY_TIMEOUT ,
79
- INSTANCE_CLOSED ,
80
- SERVICE_STOPPED_BEFORE_RUNNING
81
78
} from 'error_message' ;
82
79
83
80
import {
@@ -98,6 +95,8 @@ import {
98
95
VARIABLE_NOT_USED_RETURN_DEFAULT_VARIABLE_VALUE ,
99
96
} from 'log_message' ;
100
97
98
+ import { SERVICE_STOPPED_BEFORE_RUNNING } from '../service' ;
99
+
101
100
import { ErrorNotifier } from '../error/error_notifier' ;
102
101
import { ErrorReporter } from '../error/error_reporter' ;
103
102
import { OptimizelyError } from '../error/optimizly_error' ;
@@ -113,6 +112,9 @@ type StringInputs = Partial<Record<InputKey, unknown>>;
113
112
114
113
type DecisionReasons = ( string | number ) [ ] ;
115
114
115
+ export const INSTANCE_CLOSED = 'Instance closed' ;
116
+ export const ONREADY_TIMEOUT = 'onReady timeout expired after %s ms' ;
117
+
116
118
/**
117
119
* options required to create optimizely object
118
120
*/
@@ -1257,7 +1259,9 @@ export default class Optimizely extends BaseService implements Client {
1257
1259
}
1258
1260
1259
1261
if ( ! this . isRunning ( ) ) {
1260
- this . startPromise . reject ( new OptimizelyError ( SERVICE_STOPPED_BEFORE_RUNNING ) ) ;
1262
+ this . startPromise . reject ( new Error (
1263
+ sprintf ( SERVICE_STOPPED_BEFORE_RUNNING , 'Client' )
1264
+ ) ) ;
1261
1265
}
1262
1266
1263
1267
this . state = ServiceState . Stopping ;
@@ -1322,14 +1326,16 @@ export default class Optimizely extends BaseService implements Client {
1322
1326
1323
1327
const onReadyTimeout = ( ) => {
1324
1328
this . cleanupTasks . delete ( cleanupTaskId ) ;
1325
- timeoutPromise . reject ( new OptimizelyError ( ONREADY_TIMEOUT , timeoutValue ) ) ;
1329
+ timeoutPromise . reject ( new Error (
1330
+ sprintf ( ONREADY_TIMEOUT , timeoutValue )
1331
+ ) ) ;
1326
1332
} ;
1327
1333
1328
1334
const readyTimeout = setTimeout ( onReadyTimeout , timeoutValue ) ;
1329
1335
1330
1336
this . cleanupTasks . set ( cleanupTaskId , ( ) => {
1331
1337
clearTimeout ( readyTimeout ) ;
1332
- timeoutPromise . reject ( new OptimizelyError ( INSTANCE_CLOSED ) ) ;
1338
+ timeoutPromise . reject ( new Error ( INSTANCE_CLOSED ) ) ;
1333
1339
} ) ;
1334
1340
1335
1341
return Promise . race ( [ this . onRunning ( ) . then ( ( ) => {
0 commit comments