Skip to content

Commit e1d1c2d

Browse files
author
Jackson Dean
committed
fix: Handle possible fs.stat failure gracefully.
1 parent e26563a commit e1d1c2d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/@css-blocks/language-server/src/util/blockUtils.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,18 @@ async function getImportPathCompletions(documentUri: string, relativeImportPath:
8787
fs.readdir(absoluteScanDir, (_, paths) => r(paths || []));
8888
});
8989

90-
let fileInfos: PathCompletionCandidateInfo[] = await Promise.all(pathNames.map(pathName => {
90+
let fileInfos: (PathCompletionCandidateInfo | null)[] = await Promise.all(pathNames.map(pathName => {
9191
return new Promise(r => {
9292
let absolutePath = `${absoluteScanDir}/${pathName}`;
93-
fs.stat(absolutePath, (_, stats) => r({ pathName: absolutePath, stats }));
93+
fs.stat(absolutePath, (_, stats) => r(
94+
stats ? { pathName: absolutePath, stats } : null,
95+
));
9496
});
9597
}));
9698

9799
return fileInfos.reduce(
98100
(completionItems: CompletionItem[], fileInfo) => {
99-
if (fileInfo.pathName === blockFsPath) {
101+
if (!fileInfo || fileInfo.pathName === blockFsPath) {
100102
return completionItems;
101103
}
102104

0 commit comments

Comments
 (0)