{"record":{"id":"fa1dfe12ef97fabc","repo":"facebook/relay","slug":"error","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-lsp/src/server/lsp_state_resources.rs","lineNumber":106,"sourceCode":"            update_in_progress_status(\n                \"Relay: watchman...\",\n                Some(\"Sending watchman query to get source files and possible saved state\"),\n                &self.lsp_state.sender,\n            );\n            let setup_event = self\n                .lsp_state\n                .perf_logger\n                .create_event(\"lsp_state_initialize_resources\");\n            let timer = setup_event.start(\"lsp_state_initialize_resources_time\");\n\n            let file_source = match FileSource::connect(&self.lsp_state.config, &setup_event).await\n            {\n                Ok(f) => f,\n                Err(error) => {\n                    self.log_errors(\"watch_build_error\", &error);\n                    error_count += 1;\n                    if error_count == MAX_ERROR_COUNT {\n                        panic!(\"{}\", error);\n                    }\n                    continue;\n                }\n            };\n            let (mut compiler_state, file_source_subscription) = match file_source\n                .subscribe(&setup_event, self.lsp_state.perf_logger.as_ref())\n                .await\n            {\n                Ok(f) => f,\n                Err(error) => {\n                    self.log_errors(\"watch_build_error\", &error);\n                    error_count += 1;\n                    if error_count == MAX_ERROR_COUNT {\n                        panic!(\"{}\", error);\n                    }\n                    continue;\n                }\n            };","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-lsp/src/server/lsp_state_resources.rs#L88-L124","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure config and schema are valid before starting the LSP\nif (!fs.existsSync(relayConfigPath)) throw new Error('relay.config missing');","typeGuard":null,"tryCatchPattern":"process.on('uncaughtException', (e) => { logError('relay-lsp panic', e); process.exit(1); }); // restart LSP after fixing the logged watch_build_error","preventionTips":["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"],"tags":["lsp","watch","build","panic"],"backgroundTag":"repeated-build-failure","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}