Skip to content

Commit

Permalink
Revert "fix: LSP server crashing in case of error in schema" (#3466)
Browse files Browse the repository at this point in the history
This reverts commit 57c2d7f.
  • Loading branch information
acao authored Nov 20, 2023
1 parent d07d5fc commit f423c1c
Showing 1 changed file with 34 additions and 39 deletions.
73 changes: 34 additions & 39 deletions packages/graphql-language-service-server/src/MessageProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,47 +664,42 @@ export class MessageProcessor {
await this._updateFragmentDefinition(uri, contents);
await this._updateObjectTypeDefinition(uri, contents);

try {
const project = this._graphQLCache.getProjectForFile(uri);
if (project) {
await this._updateSchemaIfChanged(project, uri);
}

let diagnostics: Diagnostic[] = [];

if (
project?.extensions?.languageService?.enableValidation !== false
) {
diagnostics = (
await Promise.all(
contents.map(async ({ query, range }) => {
const results = await this._languageService.getDiagnostics(
query,
uri,
this._isRelayCompatMode(query),
);
if (results && results.length > 0) {
return processDiagnosticsMessage(results, query, range);
}
return [];
}),
)
).reduce((left, right) => left.concat(right), diagnostics);
}
const project = this._graphQLCache.getProjectForFile(uri);
if (project) {
await this._updateSchemaIfChanged(project, uri);
}

this._logger.log(
JSON.stringify({
type: 'usage',
messageType: 'workspace/didChangeWatchedFiles',
projectName: project?.name,
fileName: uri,
}),
);
return { uri, diagnostics };
} catch (err) {
this._handleConfigError({ err, uri });
return { uri, diagnostics: [] };
let diagnostics: Diagnostic[] = [];

if (
project?.extensions?.languageService?.enableValidation !== false
) {
diagnostics = (
await Promise.all(
contents.map(async ({ query, range }) => {
const results = await this._languageService.getDiagnostics(
query,
uri,
this._isRelayCompatMode(query),
);
if (results && results.length > 0) {
return processDiagnosticsMessage(results, query, range);
}
return [];
}),
)
).reduce((left, right) => left.concat(right), diagnostics);
}

this._logger.log(
JSON.stringify({
type: 'usage',
messageType: 'workspace/didChangeWatchedFiles',
projectName: project?.name,
fileName: uri,
}),
);
return { uri, diagnostics };
}
if (change.type === FileChangeTypeKind.Deleted) {
await this._graphQLCache.updateFragmentDefinitionCache(
Expand Down

0 comments on commit f423c1c

Please sign in to comment.