oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
71.78k stars 2.55k forks source link

`@edgedb/generate` scripts not executing properly with `bun` version 1.1.10 #11453

Open mcisne4 opened 1 month ago

mcisne4 commented 1 month ago

What version of Bun is running?

1.1.9+bb13798d9

What platform is your computer?

Linux 6.5.0-35-generic x86_64 x86_64

What steps can reproduce the bug?

The latest version of bun (v1.1.10) has potential incompatibilities with EdgeDB's TypeScript/JavaScript generators. #1032

When using the latest version of bun (v1.1.10), the bunx @edgedb/generate queries and the bunx @edgedb/generate interfaces scripts do not fully execute. Execution of the scripts starts properly but suddenly terminates after attempting to connect to the database. No errors are emitted, execution just stops. No files are generated as a result.

The above issue is resolved if I roll back to the previous version of bun (v1.1.9).

Quick Project Setup:

# Initialize Bun Project
mkdir edgedb-project && cd edgedb-project
bun init

# Add EdgeDB Dependencies:
bun add edgedb
bun add -D @edgedb/generate

# Initialize EdgeDB:
edgedb project init

# Add Schema Information
cat > dbschema/default.esdl << EOF
module default {
  type Person {
    name: str;
  }
}
EOF

# Schema Migration:
edgedb migration create
edgedb migrate

# Add EdgeBD Query:
mkdir queries
cat > queries/insertPerson.edgeql << EOF
insert Person {
  name := <str>\$name
}
EOF

Bug: Executing the queries or interfaces command should generate database related TypeScript files.

# Queries Generator:
bunx @edgedb/generate queries

# Interfaces Generator:
bunx @edgedb/generate interfaces

When using bun version 1.1.10, execution does not complete and no files are generated. When using version 1.1.9 or older, the files are generated successfully.

What is the expected behavior?

Executing the queries generation script:

# [Bun v1.1.9]
# Proper Execution:
> bunx @edgedb/generate queries
Generating functions from .edgeql files...
Detected tsconfig.json, generating TypeScript files.
   To override this, use the --target flag.
   Run `npx @edgedb/generate --help` for full options.
Detected project root via edgedb.toml:
   /home/mcisne4/dev/bun/experiment-26
Detected schema directory: dbschema
Connecting to database...
Analyzing .edgeql files...
Generating files for following queries:
   ./queries/insertXYZ.query.ts

Executing the interfaces generation script:

# [Bun v1.1.9]
# Proper Execution:
> bunx @edgedb/generate interfaces
Generating TS interfaces from schema...
Introspecting database schema...
Generating interfaces...
Writing interfaces file...
   ./dbschema/interfaces.ts
Generation complete! 🤘

What do you see instead?

Executing the queries generation script

# [Bun v1.1.10]
# Improper Execution:
> bunx @edgedb/generate queries
Generating functions from .edgeql files...
Detected tsconfig.json, generating TypeScript files.
   To override this, use the --target flag.
   Run `npx @edgedb/generate --help` for full options.
Detected project root via edgedb.toml:
   /home/mcisne4/dev/bun/experiment-26
Detected schema directory: dbschema
Connecting to database...

Executing the interfaces generation script:

# [Bun v1.1.10]
# Improper Execution:
> bunx @edgedb/generate interfaces
Generating TS interfaces from schema...
Introspecting database schema...

Additional information

No response

corbinu commented 6 days ago

@mcisne4 I am not seeing this issue when using the latest bun and edgedb. Can you try again?

Thanks!

mcisne4 commented 5 days ago

@corbinu I have been getting things to work by installing Node alongside Bun. Previously I was only running on Bun.

To check that it wasn't my system, I tried it again on a fresh install of Ubuntu 23.10 (in preview mode). I installed Bun and EdgeDB and tried the above steps again.

Bun v1.1.9 | No Node - Everything works as expected

Bun v1.1.10 | No Node - ...forgot to test

Bun v1.1.17 | No Node - The generation commands do not execute completely. No errors are thrown.

Bun v1.1.17 | Node v22.3.0 - Everything works as expected

The bug seems to persist with the latest version of Bun if Node is not present. However, everything works as expected when rolling back to Bun v1.1.9, without the need to also have Node installed.

NOTE: I have not tried the above steps in the latest Ubuntu version, which would be a better target

corbinu commented 2 days ago

@mcisne4 I installed bun in a brand new lubuntu vm with no node and can confirm this is still an issue. Thanks!