edgedb / edgedb-js

The official TypeScript/JS client library and query builder for EdgeDB
https://edgedb.com
Apache License 2.0
515 stars 66 forks source link

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

Open scotttrinh opened 1 year ago

scotttrinh commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

scotttrinh commented 1 year ago

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