[lsp-server] 🐞 LSP crash on multi-root mono-repo when schema file contains error.
- Dominant language
- TypeScript
- Stars
- 16.9k
- Forks
- 1.9k
- Avg merge
- 22h 45m
- Merged PRs (30d)
- 70
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Current Behavior
LSP crash when schema file contains error in multi-project monorepo.
```log
/home/charles/.vscode-server/extensions/graphql.vscode-graphql-0.8.19/out/server/index.js:4640
'${t.documents}'`),this._logger.error(String(r))}}async _cacheAllProjectFiles(t){if(t?.projects)return Promise.all(Object.keys(t.projects).map(async r=>{let n=t.getProject(r);await this._cacheSchemaFilesForProject(n),await this._cacheDocumentFilesforProject(n)}))}_isRelayCompatMode(t){return t.includes("RelayCompat")||t.includes("react-relay/compat")}async _updateFragmentDefinition(t,r){let n=this._graphQLCache.getGraphQLConfig().dirpath;await this._graphQLCache.updateFragmentDefinition(n,t,r)}async _updateSchemaIfChanged(t,r){await Promise.all(this._unwrapProjectSchema(t).map(async n=>{let i=Dx.resolve(t.dirpath,n);uV.URI.parse(r).fsPath===i&&await this._graphQLCache.invalidateSchemaCacheForProject(t)}))}_unwrapProjectSchema(t){let r=t.schema,n=[];if(typeof r=="string")n.push(r);else if(Array.isArray(r))for(let i of r)typeof i=="string"?n.push(i):i&&n.push(...Object.keys(i));else {console.log(r);n.push(...Object.keys(r))};return n}async _updateObjectTypeDefinition(t,r){let n=this._graphQLCache.getGraphQLConfig().dirpath;await this._graphQLCache.updateObjectTypeDefinition(n,t,r)}_getCachedDocument(t){if(this._textDocumentCache.has(t)){let r=this._textDocumentCache.get(t);if(r)return r}return null}async _invalidateCache(t,r,n){var i;if(this._textDocumentCache.has(r)){let a=this._textDocumentCache.get(r);if(a&&t&&t?.version&&a.version)
at QGe._unwrapProjectSchema (/home/charles/.vscode-server/extensions/graphql.vscode-graphql-0.8.19/out/server/index.js:4640:929)
at QGe._updateSchemaIfChanged (/home/charles/.vscode-server/extensions/graphql.vscode-graphql-0.8.19/out/server/index.js:4640:558)
at /home/charles/.vscode-server/extensions/graphql.vscode-graphql-0.8.19/out/server/index.js:4635:5335
at async Promise.all (index 0)
```
### Expected Behavior
Act as normal.
### Steps To Reproduce
Insert some error in schema file and save.
Error occurs when projectSchema is undefined. But I have an array of schema in .graphqlrc.
### Environment
* LSP Server Version: 5.0.2
* OS: Ubuntu 20.04
* LSP Client: vscode-graphql
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.