facebook / facebook/relay

Relay compiler panics if the schema file path starts with `./` and watchman is being used

Open
#4,897 0 comments 0 reactions 0 assignees View on GitHub
shared with relay team
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

It seems Watchman does not interpret paths with `./` in the same what that our checks for the existence of the file does. The result is that our initial validation ensuring we have a schema file passes, but when we initialize the project, no schema file is discovered by Watchman and thus when the compiler goes to look up the schema it panics.

I haven't been able to locate exactly the specification for what type of path Watchman expects, but I think we need to either find a way to correctly transform arbitrary paths into that format, or add validation which rejects configs which are not already in that format.

This is potentially a pretty big footgun for adopters of Relay. I myself hit it trying to setup a small project to repro an unrelated issue.

The invalid watchman file paths get constructed here: https://github.com/facebook/relay/blob/9b90142ae8135ac2bc5b42f9b6b093ba629beb0e/compiler/crates/relay-compiler/src/file_source/watchman_query_builder.rs#L56

Validating that the schema file exists is done here:

https://github.com/facebook/relay/blob/9b90142ae8135ac2bc5b42f9b6b093ba629beb0e/compiler/crates/relay-compiler/src/config.rs#L588-L599

Contributor guide

Open the contributing guide

Research direction

Start by reading compiler/crates/relay-compiler/src/file_source/watchman_query_builder.rs around line 56 and compiler/crates/relay-compiler/src/config.rs around lines 588-599. Reproduce the configuration with a schema path beginning `./` while using Watchman, then trace the differing path handling. Done means the schema is discovered consistently and the compiler no longer panics.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.