From f423c1ca6fe228c26b2f1acf03e1cee3d42fe955 Mon Sep 17 00:00:00 2001 From: Rikki Schulte Date: Mon, 20 Nov 2023 13:39:09 +0100 Subject: [PATCH] Revert "fix: LSP server crashing in case of error in schema" (#3466) This reverts commit 57c2d7fbb250d0178bbc51c9f971e8ac1c77f2a9. --- .../src/MessageProcessor.ts | 73 +++++++++---------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/packages/graphql-language-service-server/src/MessageProcessor.ts b/packages/graphql-language-service-server/src/MessageProcessor.ts index 3d916c77954..4772d8f1058 100644 --- a/packages/graphql-language-service-server/src/MessageProcessor.ts +++ b/packages/graphql-language-service-server/src/MessageProcessor.ts @@ -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(