1
+ import { once } from 'events' ;
1
2
import { ChildProcess } from 'child_process' ;
2
3
import { MongoClientOptions } from '@mongosh/service-provider-core' ;
3
4
import { Runtime } from '@mongosh/browser-runtime-core' ;
@@ -16,22 +17,24 @@ class WorkerEvaluationListener {
16
17
this . exposedListener = exposeAll < EvaluationListener > (
17
18
{
18
19
onPrompt ( question , type ) {
19
- return workerRuntime . evaluationListener . onPrompt ?.( question , type ) ?? '' ;
20
+ return (
21
+ workerRuntime . evaluationListener ?. onPrompt ?.( question , type ) ?? ''
22
+ ) ;
20
23
} ,
21
24
onPrint ( values ) {
22
25
return workerRuntime . evaluationListener ?. onPrint ?.( values ) ;
23
- }
24
26
} ,
25
27
toggleTelemetry ( enabled ) {
26
28
return workerRuntime . evaluationListener ?. toggleTelemetry ?.( enabled ) ;
27
- }
28
29
} ,
29
30
onClearCommand ( ) {
30
- return workerRuntime . evaluationListener . onClearCommand ?.( ) ;
31
+ return workerRuntime . evaluationListener ? .onClearCommand ?.( ) ;
31
32
} ,
32
33
onExit ( ) {
33
- return workerRuntime . evaluationListener ?. onExit ?.( ) ??
34
- Promise . resolve ( ) as Promise < never > ;
34
+ return (
35
+ workerRuntime . evaluationListener ?. onExit ?.( ) ??
36
+ ( Promise . resolve ( ) as Promise < never > )
37
+ ) ;
35
38
}
36
39
} ,
37
40
childProcess
@@ -102,7 +105,10 @@ class WorkerRuntime implements Runtime {
102
105
async terminate ( ) {
103
106
await this . initWorkerPromise ;
104
107
this . childProcess . kill ( 'SIGTERM' ) ;
105
- if ( this . childProcess . exitCode === null && this . childProcess . signalCode === null ) {
108
+ if (
109
+ this . childProcess . exitCode === null &&
110
+ this . childProcess . signalCode === null
111
+ ) {
106
112
await once ( this . childProcess , 'exit' ) ;
107
113
}
108
114
}
0 commit comments