facebook / relay

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

[relay 13] Watchman queries from compiler not supported on latest (homebrew) watchman #3674

Open orta opened 2 years ago

orta commented 2 years ago

I updated watchman to the latest homebrew build, which is v2021.11.15.00 (there has been one new version since then, but its very difficult to know what changed as an outsider) but this query fails:

❯ yarn relay-compiler --schema ../.redwood/schema.graphql
yarn run v1.22.17
$ /Users/ortatherox/dev/redwood/relay-redwood-app-example/node_modules/.bin/relay-compiler --schema ../.redwood/schema.graphql
querying files to compile...
[ERROR] Watchman error: The watchman server reported an error: "failed to parse query: must use ["suffix", "suffixstring"]", while executing command: QueryRequest(
    "query",
    "/Users/ortatherox/dev/redwood/relay-redwood-app-example",
    QueryRequestCommon {
        glob: None,
        glob_noescape: false,
        glob_includedotfiles: false,
        path: Some(
            [
                RecursivePath(
                    "",
                ),
            ],
        ),
        suffix: None,
        since: None,
        relative_root: Some(
            "web",
        ),
        expression: Some(
            All(
                [
                    FileType(
                        Regular,
                    ),
                    Any(
                        [
                            All(
                                [
                                    All(
                                        [
                                            Suffix(
                                                [
                                                    "ts",
                                                    "tsx",
                                                ],
                                            ),
                                            DirName(
                                                DirNameTerm {
                                                    path: "",
                                                    depth: None,
                                                },
                                            ),
                                        ],
                                    ),
                                    Not(
                                        Any(
                                            [
                                                Match(
                                                    MatchTerm {
                                                        glob: "**/node_modules/**",
                                                        wholename: true,
                                                        include_dot_files: false,
                                                        no_escape: false,
                                                    },
                                                ),
                                                Match(
                                                    MatchTerm {
                                                        glob: "**/__mocks__/**",
                                                        wholename: true,
                                                        include_dot_files: false,
                                                        no_escape: false,
                                                    },
                                                ),
                                                Match(
                                                    MatchTerm {
                                                        glob: "**/__generated__/**",
                                                        wholename: true,
                                                        include_dot_files: false,
                                                        no_escape: false,
                                                    },
                                                ),
                                            ],
                                        ),
                                    ),
                                ],
                            ),
                            Name(
                                NameTerm {
                                    paths: [
                                        "schema.graphql",
                                    ],
                                    wholename: true,
                                },
                            ),
                        ],
                    ),
                ],
            ),
        ),
        fields: [
            "name",
            "exists",
        ],
        empty_on_fresh_instance: false,
        omit_changed_files: false,
        fail_if_no_saved_state: false,
        case_sensitive: false,
        sync_timeout: Default,
        dedup_results: false,
        lock_timeout: None,
        request_id: None,
    },
)
[ERROR] Compilation failed.
[ERROR] Watchman error: The watchman server reported an error: "failed to parse query: must use ["suffix", "suffixstring"]", while executing command: QueryRequest(
    "query",
    "/Users/ortatherox/dev/redwood/relay-redwood-app-example",
    QueryRequestCommon {
        glob: None,
        glob_noescape: false,
        glob_includedotfiles: false,
        path: Some(
            [
                RecursivePath(
                    "",
                ),
            ],
        ),
        suffix: None,
        since: None,
        relative_root: Some(
            "web",
        ),
        expression: Some(
            All(
                [
                    FileType(
                        Regular,
                    ),
                    Any(
                        [
                            All(
                                [
                                    All(
                                        [
                                            Suffix(
                                                [
                                                    "ts",
                                                    "tsx",
                                                ],
                                            ),
                                            DirName(
                                                DirNameTerm {
                                                    path: "",
                                                    depth: None,
                                                },
                                            ),
                                        ],
                                    ),
                                    Not(
                                        Any(
                                            [
                                                Match(
                                                    MatchTerm {
                                                        glob: "**/node_modules/**",
                                                        wholename: true,
                                                        include_dot_files: false,
                                                        no_escape: false,
                                                    },
                                                ),
                                                Match(
                                                    MatchTerm {
                                                        glob: "**/__mocks__/**",
                                                        wholename: true,
                                                        include_dot_files: false,
                                                        no_escape: false,
                                                    },
                                                ),
                                                Match(
                                                    MatchTerm {
                                                        glob: "**/__generated__/**",
                                                        wholename: true,
                                                        include_dot_files: false,
                                                        no_escape: false,
                                                    },
                                                ),
                                            ],
                                        ),
                                    ),
                                ],
                            ),
                            Name(
                                NameTerm {
                                    paths: [
                                        "schema.graphql",
                                    ],
                                    wholename: true,
                                },
                            ),
                        ],
                    ),
                ],
            ),
        ),
        fields: [
            "name",
            "exists",
        ],
        empty_on_fresh_instance: false,
        omit_changed_files: false,
        fail_if_no_saved_state: false,
        case_sensitive: false,
        sync_timeout: Default,
        dedup_results: false,
        lock_timeout: None,
        request_id: None,
    },
)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I wondered if the prefix was src or artifactDirectory not being set maybe, but:

yarn relay-compiler --schema ../.redwood/schema.graphql --src ./src --artifactDirectory src/components/__generated__

Also fails, if you want a repro: https://github.com/orta/relay-redwood-app-example/tree/relay_13

AndrewIngram commented 2 years ago

I had to restart the watchman process after upgrading it to the latest version:

watchman shutdown-server
orta commented 2 years ago

Ace, that fixed it for me also. Part of me wants to say that relay should probably version detect on watchman, it should get sent the version number / feature detction during the watchman client bootstrapping, so I'll leave this open.

orta commented 2 years ago

Related: #3433

alunyov commented 2 years ago

Thanks for reporting the issue @orta! I agree that we should probably check the version/capabilities of watchman and give a better error message in this case with recommendations on how to possibly fix this.

pkrakesh commented 3 days ago

Watchman 2024.09.23.00 installed with Homebrew. I am also experiencing the same error.