Skip to content

Commit 484c052

Browse files
authored
Improve the document cache miss error message (#2161)
1 parent 5852ba4 commit 484c052

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.changeset/chilly-birds-poke.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"graphql-language-service-server": patch
3+
"graphql-language-service": patch
4+
---
5+
6+
Do not log errors when a JS/TS file has no embedded graphql tags

packages/graphql-language-service-server/src/MessageProcessor.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ export class MessageProcessor {
485485

486486
const cachedDocument = this._getCachedDocument(textDocument.uri);
487487
if (!cachedDocument) {
488-
throw new Error('A cached document cannot be found.');
488+
return [];
489489
}
490490

491491
const found = cachedDocument.contents.find(content => {
@@ -537,7 +537,7 @@ export class MessageProcessor {
537537

538538
const cachedDocument = this._getCachedDocument(textDocument.uri);
539539
if (!cachedDocument) {
540-
throw new Error('A cached document cannot be found.');
540+
return { contents: [] };
541541
}
542542

543543
const found = cachedDocument.contents.find(content => {
@@ -749,8 +749,9 @@ export class MessageProcessor {
749749
const textDocument = params.textDocument;
750750
const cachedDocument = this._getCachedDocument(textDocument.uri);
751751
if (!cachedDocument || !cachedDocument.contents[0]) {
752-
throw new Error('A cached document cannot be found.');
752+
return [];
753753
}
754+
754755
return this._languageService.getDocumentSymbols(
755756
cachedDocument.contents[0].query,
756757
textDocument.uri,

0 commit comments

Comments
 (0)