From 68d6110d76fa3fabbedccb91ead34f9f3189c2e3 Mon Sep 17 00:00:00 2001 From: William Killerud Date: Thu, 25 Jul 2024 21:17:51 +0200 Subject: [PATCH] fix: don't crash on ENOENT when looking up realPath Fixes #182 --- packages/language-server/src/node-file-system.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/language-server/src/node-file-system.ts b/packages/language-server/src/node-file-system.ts index 9e7a8cb5..cc578f28 100644 --- a/packages/language-server/src/node-file-system.ts +++ b/packages/language-server/src/node-file-system.ts @@ -55,8 +55,14 @@ export class NodeFileSystem implements FileSystemProvider { } async realPath(uri: URI): Promise { - const fsPath = await promises.realpath(uri.fsPath); - return URI.file(fsPath); + try { + const fsPath = await promises.realpath(uri.fsPath); + return URI.file(fsPath); + } catch (e) { + // Not all links we get here point to real files or symlinks on disk. + // Fall back to returning the same URI (#184). + return uri; + } } async stat(uri: URI): Promise {