edgedb-js icon indicating copy to clipboard operation
edgedb-js copied to clipboard

Using multiple user-defined modules causes the language server to behave incorrectly

Open scotttrinh opened this issue 1 year ago • 3 comments

Simple reproduction case here: https://github.com/quinnvaughn/reproduction Discord conversation here: https://discord.com/channels/841451783728529451/1102466847271559258


Having done a little bit of debugging in the language server, I was able to confirm that there are certain times when the language server gets garbage data when trying to get completions during the formatting step. The formatting step is what determines where to insert the completion so that accepting the completion does the right thing, but for some reason in some cases, it returns non-sense which fails an assertion in the language server and fails to return completions for the return type expected.

It seems related to using some third-party libraries to generate GraphQL queries. These libraries also have pretty complex types, so there seems to be some weird interplay between our generated code and these libraries. Examples we've checked include pothos, type-graphql, and nexus.


When trying to debug this, we tried switching to using a single file to express all of the modules and that does seem to have "fixed" it at least in all of the cases that we've tried so far.

scotttrinh avatar May 04 '23 17:05 scotttrinh

Looks like it's unrelated to the number of files, it's related to the number of (user-defined) modules. It doesn't even seem like you need to actually reference the modules across each other.

scotttrinh avatar May 04 '23 19:05 scotttrinh

And the plot thickens: the same pathological behavior can be triggered with only a single module, but in different ways.

scotttrinh avatar May 04 '23 19:05 scotttrinh

Seems fairly similar to https://github.com/microsoft/TypeScript/issues/51905, so I'm going to also keep an eye on this.

scotttrinh avatar May 08 '23 17:05 scotttrinh