@@ -39,6 +39,25 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
39
39
40
40
protected uploading = false ;
41
41
42
+ private outputString : string ;
43
+
44
+ private FLUSH_OUTPUT_MESSAGES_TIMEOUT_MS = 32 ;
45
+
46
+ private flushOutputMessagesInterval ?: NodeJS . Timeout ;
47
+
48
+ setOutputMessagesInterval ( ) : void {
49
+ this . flushOutputMessagesInterval = setInterval ( ( ) => {
50
+ this . responseService . appendToOutput ( {
51
+ chunk : this . outputString ,
52
+ } ) ;
53
+ } , this . FLUSH_OUTPUT_MESSAGES_TIMEOUT_MS ) ;
54
+ }
55
+
56
+ clearOutputMessagesInterval ( ) : void {
57
+ clearInterval ( this . flushOutputMessagesInterval ) ;
58
+ this . flushOutputMessagesInterval = undefined ;
59
+ }
60
+
42
61
async compile (
43
62
options : CoreService . Compile . Options & {
44
63
exportBinaries ?: boolean ;
@@ -174,18 +193,21 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
174
193
175
194
const result = responseHandler ( client , req ) ;
176
195
196
+ this . setOutputMessagesInterval ( ) ;
197
+
177
198
try {
178
199
await new Promise < void > ( ( resolve , reject ) => {
179
200
result . on ( 'data' , ( resp : UploadResponse ) => {
180
- this . responseService . appendToOutput ( {
181
- chunk : Buffer . from ( resp . getOutStream_asU8 ( ) ) . toString ( ) ,
182
- } ) ;
183
- this . responseService . appendToOutput ( {
184
- chunk : Buffer . from ( resp . getErrStream_asU8 ( ) ) . toString ( ) ,
185
- } ) ;
201
+ this . outputString =
202
+ this . outputString +
203
+ Buffer . from ( resp . getOutStream_asU8 ( ) ) . toString ( ) +
204
+ Buffer . from ( resp . getErrStream_asU8 ( ) ) . toString ( ) ;
186
205
} ) ;
187
206
result . on ( 'error' , ( error ) => reject ( error ) ) ;
188
- result . on ( 'end' , ( ) => resolve ( ) ) ;
207
+ result . on ( 'end' , ( ) => {
208
+ this . clearOutputMessagesInterval ( ) ;
209
+ resolve ( ) ;
210
+ } ) ;
189
211
} ) ;
190
212
this . responseService . appendToOutput ( {
191
213
chunk :
0 commit comments