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
- Read the earlier 'watch_build_error' log entries to find the underlying build error and fix it.
- Restart the Relay LSP / editor after fixing config or schema problems.
- Ensure the relay config and schema paths remain valid while the server watches.
- 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
- Keep relay config/schema paths valid for the lifetime of the LSP session
- Review the watch_build_error logs at the first failure, not after the panic
- Restart the language server after config or schema changes
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
- Failed to build programs
- Duplicate fragment definitions named {}: first one: {:?} s
- Expected a key
- @__metadata directive should have only one argument!
- unexpected value for @defer if argument: {other:?}
AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02).
Data as JSON: /api/errors/fa1dfe12ef97fabc.
Report an issue: GitHub.