File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -25,17 +25,30 @@ export class PricingService implements OnModuleInit {
25
25
private worker : Worker | null = null ;
26
26
private requestPortMessageId = 0 ;
27
27
28
+ private setReady ! : ( ) => void ;
29
+ readonly isReady : Promise < void > ;
30
+
28
31
constructor (
29
32
private readonly configService : ConfigService ,
30
33
private readonly loggerService : LoggerService ,
31
- ) { }
34
+ ) {
35
+ this . isReady = this . initializeIsReady ( ) ;
36
+ }
32
37
33
38
onModuleInit ( ) {
34
39
this . loggerService . info ( `Starting Pricing worker...` ) ;
35
40
36
41
this . initializeWorker ( ) ;
37
42
38
43
this . initiateIntervalStatusLog ( ) ;
44
+
45
+ this . setReady ( ) ;
46
+ }
47
+
48
+ private initializeIsReady ( ) : Promise < void > {
49
+ return new Promise < void > ( ( resolve ) => {
50
+ this . setReady = resolve ;
51
+ } ) ;
39
52
}
40
53
41
54
private initializeWorker ( ) : void {
@@ -139,6 +152,8 @@ export class PricingService implements OnModuleInit {
139
152
140
153
async attachToPricing ( ) : Promise < MessagePort > {
141
154
155
+ await this . isReady ;
156
+
142
157
const worker = this . worker ;
143
158
if ( worker == undefined ) {
144
159
throw new Error ( `Pricing worker is null.` ) ;
You can’t perform that action at this time.
0 commit comments