@@ -59,7 +59,7 @@ import {
5959 NODE_CLIENT_ENGINE ,
6060 CLIENT_VERSION ,
6161} from '../utils/enums' ;
62- import { Fn , Maybe , OpType , OpValue } from '../utils/type' ;
62+ import { Fn , Maybe , OpType } from '../utils/type' ;
6363import { resolvablePromise } from '../utils/promise/resolvablePromise' ;
6464
6565import { NOTIFICATION_TYPES , DecisionNotificationType , DECISION_NOTIFICATION_TYPES } from '../notification_center/type' ;
@@ -75,9 +75,6 @@ import {
7575 EVENT_KEY_NOT_FOUND ,
7676 NOT_TRACKING_USER ,
7777 VARIABLE_REQUESTED_WITH_WRONG_TYPE ,
78- ONREADY_TIMEOUT ,
79- INSTANCE_CLOSED ,
80- SERVICE_STOPPED_BEFORE_RUNNING
8178} from 'error_message' ;
8279
8380import {
@@ -98,6 +95,8 @@ import {
9895 VARIABLE_NOT_USED_RETURN_DEFAULT_VARIABLE_VALUE ,
9996} from 'log_message' ;
10097
98+ import { SERVICE_STOPPED_BEFORE_RUNNING } from '../service' ;
99+
101100import { ErrorNotifier } from '../error/error_notifier' ;
102101import { ErrorReporter } from '../error/error_reporter' ;
103102import { OptimizelyError } from '../error/optimizly_error' ;
@@ -113,6 +112,9 @@ type StringInputs = Partial<Record<InputKey, unknown>>;
113112
114113type DecisionReasons = ( string | number ) [ ] ;
115114
115+ export const INSTANCE_CLOSED = 'Instance closed' ;
116+ export const ONREADY_TIMEOUT = 'onReady timeout expired after %s ms' ;
117+
116118/**
117119 * options required to create optimizely object
118120 */
@@ -1258,7 +1260,9 @@ export default class Optimizely extends BaseService implements Client {
12581260 }
12591261
12601262 if ( ! this . isRunning ( ) ) {
1261- this . startPromise . reject ( new OptimizelyError ( SERVICE_STOPPED_BEFORE_RUNNING ) ) ;
1263+ this . startPromise . reject ( new Error (
1264+ sprintf ( SERVICE_STOPPED_BEFORE_RUNNING , 'Client' )
1265+ ) ) ;
12621266 }
12631267
12641268 this . state = ServiceState . Stopping ;
@@ -1323,14 +1327,16 @@ export default class Optimizely extends BaseService implements Client {
13231327
13241328 const onReadyTimeout = ( ) => {
13251329 this . cleanupTasks . delete ( cleanupTaskId ) ;
1326- timeoutPromise . reject ( new OptimizelyError ( ONREADY_TIMEOUT , timeoutValue ) ) ;
1330+ timeoutPromise . reject ( new Error (
1331+ sprintf ( ONREADY_TIMEOUT , timeoutValue )
1332+ ) ) ;
13271333 } ;
13281334
13291335 const readyTimeout = setTimeout ( onReadyTimeout , timeoutValue ) ;
13301336
13311337 this . cleanupTasks . set ( cleanupTaskId , ( ) => {
13321338 clearTimeout ( readyTimeout ) ;
1333- timeoutPromise . reject ( new OptimizelyError ( INSTANCE_CLOSED ) ) ;
1339+ timeoutPromise . reject ( new Error ( INSTANCE_CLOSED ) ) ;
13341340 } ) ;
13351341
13361342 return Promise . race ( [ this . onRunning ( ) . then ( ( ) => {
0 commit comments