-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crash when when editing a file that doesn't belong to a project #3413
Conversation
🦋 Changeset detectedLatest commit: 6f0c1f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
330b6db
to
451fcae
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3413 +/- ##
==========================================
+ Coverage 55.75% 55.84% +0.09%
==========================================
Files 110 110
Lines 5243 5257 +14
Branches 1426 1433 +7
==========================================
+ Hits 2923 2936 +13
Misses 1897 1897
- Partials 423 424 +1
|
Yo @acao would you be able to take a look at this? At the moment loading up vscode with the graphql plugin crashes as soon as I open any non-graphql file which is very disruptive. This fixes the crashing. |
@BPScott hey there, yes thanks for this bugfix! I'll take a look this weekend and hopefully we can get it merged for next week!
|
getProjectForFile may return void when there is no project for that file. Wrap the call to updateSchemaIfChanged with a check to ensure that a project is present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finally got a chance to look, thank you @BPScott !
the one last thing that I would absolutely love to have is a unit test confirming this fix if you can provide it 🤞🏻
I might just ship it anyways because this is a nasty bug!
Now that |
@BPScott yes, excellent point! another reason why i love typescript. fix is released as v0.8.19 for vscode-graphql, 2.11.5 for the LSP, enjoy! |
When loading
vscode-graphql
it constantly crashes.In the output there's lots of
#3216 Introduced reloading the schema when a change is detected, however if you modify a file that does not belong to a schema then the project can be absent. Passing null/undefined into
_updateSchemaIfChanged
throws an error and crashes the language-service-server.This PR wraps the call to
await this._updateSchemaIfChanged(project, uri);
in a check to ensure that the project exists. This was not caught in the initial PR because the type forgetProjectForFile
is incorrect - it claims it will always return a project config, but that is not true.The
GraphQLCacheInterface
suggests that when a project is absent then the return type ofgetProjectForFile
should bevoid
, but the concrete implementation returnsnull
. I've changed the implementation to match the interface rather than the other way around to ensure the smallest impact area.I'd argue that changing the interface to
getProjectForFile: (uri: string) => GraphQLProjectConfig | null;
would make the most sense but that change to the interface is strictly a breaking change and I'd rather avoid that in a bugfix PR.