facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.41k stars 1.83k forks source link

relay-compiler panics when using fragment from base project in multi project setup #4471

Open tobias-tengler opened 1 year ago

tobias-tengler commented 1 year ago

I'm trying to setup a multi project config where one project uses another project as its base, but I'm running into the following error when using a fragment from the base project:

[INFO] querying files to compile...
[INFO] [base-project] compiling...
[INFO] [derived-project] compiling...
thread 'tokio-runtime-worker' panicked at 'Expected location for fragment baseFragment.', crates/relay-typegen/src/write.rs:495:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[INFO] [base-project] compiled documents: 1 reader, 0 normalization, 0 operation text
[ERROR] A thread that the Relay compiler spun up did not shut down gracefully: task 15 panicked
[ERROR] Compilation failed.
[ERROR] Unable to run relay compiler. Error details:
A thread that the Relay compiler spun up did not shut down gracefully: task 15 panicked

A reproduction can be found at: https://github.com/tobias-tengler/relay-multiproject-base-issue

This might not be a bug and simply a misconfiguration, but I couldn't find any examples on how to setup it up correctly...

alunyov commented 1 year ago

I wonder if this is something typescript related, as it panics in the relay-typegen. Can you try changing the language to "javascript" or "flow" and see if the error still there?

tobias-tengler commented 1 year ago

@alunyov It happens both with JavaScript and Flow as well, only the stack-trace is slightly different:

[INFO] querying files to compile...
[INFO] [base-project] compiling...
[INFO] [derived-project] compiling...
thread 'tokio-runtime-worker' panicked at 'Expected location for fragment baseFragment.', crates/relay-typegen/src/write.rs:504:29
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[INFO] [base-project] compiled documents: 1 reader, 0 normalization, 0 operation text
[ERROR] A thread that the Relay compiler spun up did not shut down gracefully: task 15 panicked
[ERROR] Compilation failed.
[ERROR] Unable to run relay compiler. Error details: 
A thread that the Relay compiler spun up did not shut down gracefully: task 15 panicked

I've switched the reproduction to use "language": "javascript".