Skip to content

Commit a6c444a

Browse files
committed
Synchronization issue in tasks problem collection
Fixes microsoft#74975
1 parent 6dbe048 commit a6c444a

3 files changed

Lines changed: 36 additions & 24 deletions

File tree

src/vs/workbench/contrib/tasks/common/problemCollectors.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ namespace ProblemCollectorEvent {
3131
}
3232

3333
export interface IProblemMatcher {
34-
processLine(line: string): Promise<void>;
34+
processLine(line: string): void;
3535
}
3636

37-
export class AbstractProblemCollector implements IDisposable {
37+
export abstract class AbstractProblemCollector implements IDisposable {
3838

3939
private matchers: INumberDictionary<ILineMatcher[]>;
4040
private activeMatcher: ILineMatcher | null;
@@ -44,6 +44,7 @@ export class AbstractProblemCollector implements IDisposable {
4444
private bufferLength: number;
4545
private openModels: IStringDictionary<boolean>;
4646
private modelListeners: IDisposable[];
47+
private tail: Promise<void>;
4748

4849
// [owner] -> AppyToKind
4950
private applyToByOwner: Map<string, ApplyToKind>;
@@ -104,6 +105,19 @@ export class AbstractProblemCollector implements IDisposable {
104105
return this._onDidStateChange.event;
105106
}
106107

108+
public processLine(line: string) {
109+
if (this.tail) {
110+
const oldTail = this.tail;
111+
this.tail = oldTail.then(() => {
112+
return this.processLineInternal(line);
113+
});
114+
} else {
115+
this.tail = this.processLineInternal(line);
116+
}
117+
}
118+
119+
protected abstract async processLineInternal(line: string): Promise<void>;
120+
107121
public dispose() {
108122
this.modelListeners.forEach(disposable => disposable.dispose());
109123
}
@@ -344,7 +358,7 @@ export class StartStopProblemCollector extends AbstractProblemCollector implemen
344358
});
345359
}
346360

347-
public async processLine(line: string): Promise<void> {
361+
protected async processLineInternal(line: string): Promise<void> {
348362
let markerMatch = this.tryFindMarker(line);
349363
if (!markerMatch) {
350364
return;
@@ -416,7 +430,7 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement
416430
}
417431
}
418432

419-
public async processLine(line: string): Promise<void> {
433+
protected async processLineInternal(line: string): Promise<void> {
420434
if (await this.tryBegin(line) || this.tryFinish(line)) {
421435
return;
422436
}

src/vs/workbench/contrib/tasks/electron-browser/terminalTaskSystem.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,14 +559,13 @@ export class TerminalTaskSystem implements ITaskSystem {
559559
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.Start, task, terminal.id));
560560
const registeredLinkMatchers = this.registerLinkMatchers(terminal, problemMatchers);
561561
const onData = terminal.onLineData((line) => {
562-
return watchingProblemMatcher.processLine(line).then(() => {
563-
if (!delayer) {
564-
delayer = new Async.Delayer(3000);
565-
}
566-
delayer.trigger(() => {
567-
watchingProblemMatcher.forceDelivery();
568-
delayer = undefined;
569-
});
562+
watchingProblemMatcher.processLine(line);
563+
if (!delayer) {
564+
delayer = new Async.Delayer(3000);
565+
}
566+
delayer.trigger(() => {
567+
watchingProblemMatcher.forceDelivery();
568+
delayer = undefined;
570569
});
571570
});
572571
const onExit = terminal.onExit((exitCode) => {
@@ -639,7 +638,7 @@ export class TerminalTaskSystem implements ITaskSystem {
639638
let startStopProblemMatcher = new StartStopProblemCollector(problemMatchers, this.markerService, this.modelService, ProblemHandlingStrategy.Clean, this.fileService);
640639
const registeredLinkMatchers = this.registerLinkMatchers(terminal, problemMatchers);
641640
const onData = terminal.onLineData((line) => {
642-
return startStopProblemMatcher.processLine(line);
641+
startStopProblemMatcher.processLine(line);
643642
});
644643
const onExit = terminal.onExit((exitCode) => {
645644
onData.dispose();

src/vs/workbench/contrib/tasks/node/processTaskSystem.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,15 @@ export class ProcessTaskSystem implements ITaskSystem {
258258
const onProgress = (progress: LineData) => {
259259
let line = Strings.removeAnsiEscapeCodes(progress.line);
260260
this.appendOutput(line + '\n');
261-
return watchingProblemMatcher.processLine(line).then(() => {
262-
if (delayer === null) {
263-
delayer = new Async.Delayer(3000);
264-
}
265-
delayer.trigger(() => {
266-
watchingProblemMatcher.forceDelivery();
267-
return null;
268-
}).then(() => {
269-
delayer = null;
270-
});
261+
watchingProblemMatcher.processLine(line);
262+
if (delayer === null) {
263+
delayer = new Async.Delayer(3000);
264+
}
265+
delayer.trigger(() => {
266+
watchingProblemMatcher.forceDelivery();
267+
return null;
268+
}).then(() => {
269+
delayer = null;
271270
});
272271
};
273272
const startPromise = this.childProcess.start(onProgress);
@@ -323,7 +322,7 @@ export class ProcessTaskSystem implements ITaskSystem {
323322
const onProgress = (progress: LineData) => {
324323
let line = Strings.removeAnsiEscapeCodes(progress.line);
325324
this.appendOutput(line + '\n');
326-
return startStopProblemMatcher.processLine(line);
325+
startStopProblemMatcher.processLine(line);
327326
};
328327
const startPromise = this.childProcess.start(onProgress);
329328
this.childProcess.pid.then(pid => {

0 commit comments

Comments
 (0)