Skip to content

Commit ff27db4

Browse files
aryaniyapsfacebook-github-bot
authored andcommitted
Disable persisted queries in validate mode (#5013)
Summary: Right now, when the CLI is run in valdiate mode with persisted queries enabled, the compiler fails with connection refused errors (when the persisting server is not available). This issue is most evident in CI pipelines when generally the persisting server won't be available. Example error message: ``` ➜ accounts (main) relay-compiler --validate ✭ [INFO] Querying files to compile... [INFO] [default] compiling... [ERROR] Error: Network error: error trying to connect: tcp connect error: Connection refused (os error 111) [ERROR] Compilation failed. [ERROR] Unable to run relay compiler. Error details: Failed to build: - Persisting operation(s) failed: - Network error: error trying to connect: tcp connect error: Connection refused (os error 111) ``` But the expected behaviour is that the query persister must be disabled in validate mode. This PR attempts to fix that. Issue(s) closed: #5007 Pull Request resolved: #5013 Reviewed By: tyao1 Differential Revision: D76442518 Pulled By: evanyeung fbshipit-source-id: 31006555d4f4b1a8fd9679dc67188884388dd0d2
1 parent 3320532 commit ff27db4

File tree

1 file changed

+20
-15
lines changed
  • compiler/crates/relay-bin/src

1 file changed

+20
-15
lines changed

compiler/crates/relay-bin/src/main.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -314,22 +314,27 @@ async fn handle_compiler_command(command: CompileCommand) -> Result<(), Error> {
314314

315315
if command.validate {
316316
config.artifact_writer = Box::<ArtifactValidationWriter>::default();
317-
}
318-
319-
config.create_operation_persister = Some(Box::new(|project_config| {
320-
project_config.persist.as_ref().map(
321-
|persist_config| -> Box<dyn OperationPersister + Send + Sync> {
322-
match persist_config {
323-
PersistConfig::Remote(remote_config) => {
324-
Box::new(RemotePersister::new(remote_config.clone()))
325-
}
326-
PersistConfig::Local(local_config) => {
327-
Box::new(LocalPersister::new(local_config.clone()))
317+
// Disable persister and persisted queries in validate mode
318+
config.create_operation_persister = None;
319+
for project_config in config.projects.values_mut() {
320+
project_config.persist = None;
321+
}
322+
} else {
323+
config.create_operation_persister = Some(Box::new(|project_config| {
324+
project_config.persist.as_ref().map(
325+
|persist_config| -> Box<dyn OperationPersister + Send + Sync> {
326+
match persist_config {
327+
PersistConfig::Remote(remote_config) => {
328+
Box::new(RemotePersister::new(remote_config.clone()))
329+
}
330+
PersistConfig::Local(local_config) => {
331+
Box::new(LocalPersister::new(local_config.clone()))
332+
}
328333
}
329-
}
330-
},
331-
)
332-
}));
334+
},
335+
)
336+
}));
337+
}
333338

334339
config.file_source_config = if should_use_watchman() {
335340
FileSourceKind::Watchman

0 commit comments

Comments
 (0)