From 4090184241beb699af21bd6780cd8cf86bb83bca Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Mon, 17 Apr 2017 15:02:29 -0700 Subject: [PATCH] Fix #24897 - Pool instead of queue result handling promises - Queuing a large number of WinJS promises that aren't actually async can lead to a stack overflow. Also this is faster. --- .../workbench/services/search/node/ripgrepTextSearch.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/services/search/node/ripgrepTextSearch.ts b/src/vs/workbench/services/search/node/ripgrepTextSearch.ts index f4fedc8d03a..b71976898b3 100644 --- a/src/vs/workbench/services/search/node/ripgrepTextSearch.ts +++ b/src/vs/workbench/services/search/node/ripgrepTextSearch.ts @@ -26,7 +26,7 @@ export class RipgrepEngine { private ripgrepParser: RipgrepParser; - private handleResultP: TPromise = TPromise.wrap(null); + private resultsHandledP: TPromise = TPromise.wrap(null); constructor(private config: IRawSearch) { } @@ -66,13 +66,14 @@ export class RipgrepEngine { this.ripgrepParser.on('result', (match: ISerializedFileMatch) => { if (this.postProcessExclusions) { const relativePath = path.relative(rootFolder, match.path); - this.handleResultP = this.handleResultP - .then(() => (>this.postProcessExclusions(relativePath, undefined, () => getSiblings(match.path)))) + const handleResultP = (>this.postProcessExclusions(relativePath, undefined, () => getSiblings(match.path))) .then(globMatch => { if (!globMatch) { onResult(match); } }); + + this.resultsHandledP = TPromise.join([this.resultsHandledP, handleResultP]); } else { onResult(match); } @@ -102,7 +103,7 @@ export class RipgrepEngine { this.rgProc.on('close', code => { // Trigger last result, then wait on async result handling this.ripgrepParser.flush(); - this.handleResultP.then(() => { + this.resultsHandledP.then(() => { this.rgProc = null; if (!this.isDone) { this.isDone = true; -- GitLab