Skip to content

Commit 3c56008

Browse files
test interval for output panel
1 parent df8658e commit 3c56008

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

arduino-ide-extension/src/node/core-service-impl.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
3939

4040
protected uploading = false;
4141

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+
4261
async compile(
4362
options: CoreService.Compile.Options & {
4463
exportBinaries?: boolean;
@@ -174,18 +193,21 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
174193

175194
const result = responseHandler(client, req);
176195

196+
this.setOutputMessagesInterval();
197+
177198
try {
178199
await new Promise<void>((resolve, reject) => {
179200
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();
186205
});
187206
result.on('error', (error) => reject(error));
188-
result.on('end', () => resolve());
207+
result.on('end', () => {
208+
this.clearOutputMessagesInterval();
209+
resolve();
210+
});
189211
});
190212
this.responseService.appendToOutput({
191213
chunk:

0 commit comments

Comments
 (0)