Skip to content

Commit 94aaf38

Browse files
committed
debt - dispose one CancellationTokenSource
1 parent e3ce029 commit 94aaf38

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎src/vs/workbench/services/files/node/fileService.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,14 @@ export class FileService implements IFileService {
278278
value: void 0
279279
};
280280

281-
const contentResolverToken = new CancellationTokenSource();
281+
const contentResolverTokenSource = new CancellationTokenSource();
282282

283283
const onStatError = (error: Error) => {
284284

285285
// error: stop reading the file the stat and content resolve call
286286
// usually race, mostly likely the stat call will win and cancel
287287
// the content call
288-
contentResolverToken.cancel();
288+
contentResolverTokenSource.cancel();
289289

290290
// forward error
291291
return TPromise.wrapError(error);
@@ -353,17 +353,21 @@ export class FileService implements IFileService {
353353
// etag from the stat before we actually read the file again.
354354
if (options && options.etag) {
355355
completePromise = statsPromise.then(() => {
356-
return this.fillInContents(result, resource, options, contentResolverToken.token); // Waterfall -> only now resolve the contents
356+
return this.fillInContents(result, resource, options, contentResolverTokenSource.token); // Waterfall -> only now resolve the contents
357357
});
358358
}
359359

360360
// a fresh load without a previous etag which means we can resolve the file stat
361361
// and the content at the same time, avoiding the waterfall.
362362
else {
363-
completePromise = Promise.all([statsPromise, this.fillInContents(result, resource, options, contentResolverToken.token)]);
363+
completePromise = Promise.all([statsPromise, this.fillInContents(result, resource, options, contentResolverTokenSource.token)]);
364364
}
365365

366-
return TPromise.wrap(completePromise).then(() => result);
366+
return TPromise.wrap(completePromise).then(() => {
367+
contentResolverTokenSource.dispose();
368+
369+
return result;
370+
});
367371
}
368372

369373
private fillInContents(content: IStreamContent, resource: uri, options: IResolveContentOptions, token: CancellationToken): Thenable<any> {

0 commit comments

Comments
 (0)