@@ -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 */
@@ -1257,7 +1259,9 @@ export default class Optimizely extends BaseService implements Client {
12571259 }
12581260
12591261 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+ ) ) ;
12611265 }
12621266
12631267 this . state = ServiceState . Stopping ;
@@ -1322,14 +1326,16 @@ export default class Optimizely extends BaseService implements Client {
13221326
13231327 const onReadyTimeout = ( ) => {
13241328 this . cleanupTasks . delete ( cleanupTaskId ) ;
1325- timeoutPromise . reject ( new OptimizelyError ( ONREADY_TIMEOUT , timeoutValue ) ) ;
1329+ timeoutPromise . reject ( new Error (
1330+ sprintf ( ONREADY_TIMEOUT , timeoutValue )
1331+ ) ) ;
13261332 } ;
13271333
13281334 const readyTimeout = setTimeout ( onReadyTimeout , timeoutValue ) ;
13291335
13301336 this . cleanupTasks . set ( cleanupTaskId , ( ) => {
13311337 clearTimeout ( readyTimeout ) ;
1332- timeoutPromise . reject ( new OptimizelyError ( INSTANCE_CLOSED ) ) ;
1338+ timeoutPromise . reject ( new Error ( INSTANCE_CLOSED ) ) ;
13331339 } ) ;
13341340
13351341 return Promise . race ( [ this . onRunning ( ) . then ( ( ) => {
0 commit comments