facebook/relay · error

{}

Error message

{}

What it means

In the LSP's internal_watch loop, building the compiler program from the watched file sources can fail. Errors are logged per iteration, but once the error count hits MAX_ERROR_COUNT the daemon panics with the accumulated error's message, since continued watching without a functioning build is pointless.

Source

Thrown at compiler/crates/relay-lsp/src/server/lsp_state_resources.rs:106

            update_in_progress_status(
                "Relay: watchman...",
                Some("Sending watchman query to get source files and possible saved state"),
                &self.lsp_state.sender,
            );
            let setup_event = self
                .lsp_state
                .perf_logger
                .create_event("lsp_state_initialize_resources");
            let timer = setup_event.start("lsp_state_initialize_resources_time");

            let file_source = match FileSource::connect(&self.lsp_state.config, &setup_event).await
            {
                Ok(f) => f,
                Err(error) => {
                    self.log_errors("watch_build_error", &error);
                    error_count += 1;
                    if error_count == MAX_ERROR_COUNT {
                        panic!("{}", error);
                    }
                    continue;
                }
            };
            let (mut compiler_state, file_source_subscription) = match file_source
                .subscribe(&setup_event, self.lsp_state.perf_logger.as_ref())
                .await
            {
                Ok(f) => f,
                Err(error) => {
                    self.log_errors("watch_build_error", &error);
                    error_count += 1;
                    if error_count == MAX_ERROR_COUNT {
                        panic!("{}", error);
                    }
                    continue;
                }
            };

View on GitHub (pinned to 668b1b85e0)

Solutions

  1. Read the earlier 'watch_build_error' log entries to find the underlying build error and fix it.
  2. Restart the Relay LSP / editor after fixing config or schema problems.
  3. Ensure the relay config and schema paths remain valid while the server watches.
  4. If the root cause is flaky IO, fix the environment (mounts, permissions) before restarting.
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure config and schema are valid before starting the LSP
if (!fs.existsSync(relayConfigPath)) throw new Error('relay.config missing');

Try / catch

process.on('uncaughtException', (e) => { logError('relay-lsp panic', e); process.exit(1); }); // restart LSP after fixing the logged watch_build_error

Prevention

When it happens

Trigger: watch() is running; watch_build repeatedly fails (e.g. the file_source producer errors) and after MAX_ERROR_COUNT consecutive failures the loop panics with the last error string.

Common situations: A broken config on disk during long-lived LSP sessions; repeatedly failing builds due to syntax/schema errors in watched files; environment changes (deleted directories) while the language server is running.

Related errors


AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02). Data as JSON: /api/errors/fa1dfe12ef97fabc. Report an issue: GitHub.