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

Excessive stack depth error following upgrade to v6.0

Open blecorre-mnp opened this issue 9 months ago • 6 comments

Describe the bug When switching to Gel 6.0 and using the latest @gel/generate version, we get multiple Excessive stack depth comparing types ... errors as a result of tsc.

Reproduction Following the initialization of a new project, simply try to generate the query builder with npx @gel/generate edgeql-js --target=ts and opening the generated file casting.ts is enough to see the error on our side. Here is the result of the tsc command.

Errors  Files
     5  dbschema/edgeql-js/casting.ts:53
    16  dbschema/edgeql-js/modules/std.ts:1859
     5  dbschema/edgeql-js/operators.ts:933
     2  dbschema/edgeql-js/set.ts:150

Expected behavior It should not return any error, as things used to work fine when using older EdgeDB / Gel versions such as v5.8.

Versions

  • OS: MacOS Sequoia 15.3.1
  • EdgeDB version: 6.0+a940583
  • EdgeDB CLI version: 6.1.2+1e45048
  • @gel/generate version: 0.6.0
  • Node/Deno version: 22.10.0

blecorre-mnp avatar Feb 24 '25 10:02 blecorre-mnp

Can you share what version of TypeScript you're using here? Seems to work fine for me on a relatively complex schema with TypeScript v5.7.3 but we're always teetering on the verge on complexity so maybe there is a regressive case in a different (earlier? beta?) version of TypeScript?

scotttrinh avatar Feb 24 '25 11:02 scotttrinh

Unfortunately, we are also currently running on TypeScript v5.7.3 as well..

$ npx tsc --version
Version 5.7.3

blecorre-mnp avatar Feb 24 '25 11:02 blecorre-mnp

@scotttrinh so you have something to try the issue on, I threw together this new basic Gel project with our current production schema. I was wrong in my comment above, it only breaks when the schema reaches a certain complexity. Let's hope we can find a solution!

blecorre-mnp avatar Feb 24 '25 12:02 blecorre-mnp

OK, that is incredibly helpful, thanks for getting a repro together! I'll try to grab some time this week to dig in a bit and see if there is some specific construct that is triggering this issue. In the meantime, you might try targeting a non-ts output style like esm and see if it works without the more complicated internal constructs that the full ts target uses? Thanks again for the thorough report!

scotttrinh avatar Feb 24 '25 14:02 scotttrinh

No worries, it's the least I can do! I've managed to make things work by migrating a few types outside of Gel, into our headless CMS. I've also deleted old deprecated types. I've also tried using --target=esm on the repro, doesn't seem to work with a simple tsc --noEmit index.ts.

We have somewhat of a complex schema due to the fact that I've chosen to bet a lot on Gel's computed properties, especially for our invoicing / quotes / invoices modules. After having such a schema in production for a little more than a year now, maybe we've reached Gel's natural technical limitation?

Anyway thank you for spending time on this, I hope it wont be too much of a bother!

blecorre-mnp avatar Feb 24 '25 14:02 blecorre-mnp

After having such a schema in production for a little more than a year now, maybe we've reached Gel's natural technical limitation?

You're definitely bumping into the edges of the complexity that maybe the type-system translation that the query builder is doing between EdgeQL and TypeScript. The query builder has always been a pretty ambitious project trying to maintain the type safety for arbitrarily complex expressions 😅 Gel itself is happy with really complex schemas, though, so keep on keeping on and we'll get this patched up.

Anyway thank you for spending time on this, I hope it wont be too much of a bother!

No bother at all, this is the job 👍

scotttrinh avatar Feb 24 '25 14:02 scotttrinh