Skip to content

Commit d9b5815

Browse files
authored
Make preloading fs.readFile error resilient (#856)
* Remove browser LS console logging on init * Make preloading resilient to readFile errors
1 parent 86f2c25 commit d9b5815

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.changeset/fresh-badgers-sin.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@shopify/theme-language-server-browser': patch
3+
'@shopify/theme-language-server-common': patch
4+
---
5+
6+
Make theme preload fs.readFile error resilient

packages/theme-language-server-browser/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ export function startServer(
2323
dependencies: Dependencies,
2424
connection = getConnection(worker),
2525
) {
26-
console.info('staging server', worker, dependencies, connection);
2726
startCoreServer(connection, dependencies);
2827
}

packages/theme-language-server-common/src/documents/DocumentManager.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ export class DocumentManager {
146146
filesToLoad.map(async (file) => {
147147
// This is what is important, we are loading the file from the file system
148148
// And setting their initial version to `undefined` to mean "on disk".
149-
this.set(file, await fs.readFile(file), undefined);
149+
try {
150+
this.set(file, await fs.readFile(file), undefined);
151+
} catch (error) {
152+
console.error('Failed to preload', file, error);
153+
}
150154

151155
// This is just doing progress reporting
152156
if (++i % 10 === 0) {
@@ -155,7 +159,6 @@ export class DocumentManager {
155159
}
156160
}),
157161
);
158-
159162
progress.end('Completed');
160163
},
161164
(rootUri) => rootUri,

0 commit comments

Comments
 (0)