Skip to content

Commit 8757f67

Browse files
authored
fix #116049 (#116319)
1 parent 73c0a56 commit 8757f67

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/vs/base/common/stream.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,13 @@ export function consumeStream<T>(stream: ReadableStreamEvents<T>, reducer: IRedu
495495
return new Promise((resolve, reject) => {
496496
const chunks: T[] = [];
497497

498-
stream.on('data', data => chunks.push(data));
499498
stream.on('error', error => reject(error));
500499
stream.on('end', () => resolve(reducer(chunks)));
500+
501+
// Adding the `data` listener will turn the stream
502+
// into flowing mode. As such it is important to
503+
// add this listener last (DO NOT CHANGE!)
504+
stream.on('data', data => chunks.push(data));
501505
});
502506
}
503507

src/vs/platform/files/test/electron-browser/diskFileService.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,20 @@ flakySuite('Disk File Service', function () {
15841584
assert.strictEqual(error!.fileOperationResult, FileOperationResult.FILE_TOO_LARGE);
15851585
}
15861586

1587+
(isWindows ? test.skip /* windows: cannot create file symbolic link without elevated context */ : test)('readFile - dangling symbolic link - https://github.com/microsoft/vscode/issues/116049', async () => {
1588+
const link = URI.file(join(testDir, 'small.js-link'));
1589+
await symlink(join(testDir, 'small.js'), link.fsPath);
1590+
1591+
let error: FileOperationError | undefined = undefined;
1592+
try {
1593+
await service.readFile(link);
1594+
} catch (err) {
1595+
error = err;
1596+
}
1597+
1598+
assert.ok(error);
1599+
});
1600+
15871601
test('createFile', async () => {
15881602
return assertCreateFile(contents => VSBuffer.fromString(contents));
15891603
});

0 commit comments

Comments
 (0)