From f166d6b8922dd7101bb898975adf3895421c8ce7 Mon Sep 17 00:00:00 2001 From: Tianyu Yao Date: Fri, 11 Oct 2024 10:25:09 -0700 Subject: [PATCH] Fix dangling resolver artifact Reviewed By: gordyf Differential Revision: D64219255 fbshipit-source-id: bb6fb60e0ff840f67b25a5fe56a459b185225ac0 --- .../crates/relay-compiler/src/compiler.rs | 26 ++++++++++++++++--- .../relay-compiler/src/compiler_state.rs | 4 +++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/compiler/crates/relay-compiler/src/compiler.rs b/compiler/crates/relay-compiler/src/compiler.rs index 5bcc563495422..f167933c0b477 100644 --- a/compiler/crates/relay-compiler/src/compiler.rs +++ b/compiler/crates/relay-compiler/src/compiler.rs @@ -29,6 +29,7 @@ use crate::build_project::BuildProjectFailure; use crate::compiler_state::ArtifactMapKind; use crate::compiler_state::CompilerState; use crate::compiler_state::DocblockSources; +use crate::compiler_state::FullSources; use crate::config::Config; use crate::errors::Error; use crate::errors::Result; @@ -378,6 +379,9 @@ async fn build_projects( get_removed_docblock_artifact_source_keys(compiler_state.docblocks.get(&project_name)); removed_artifact_sources.extend(removed_docblock_artifact_sources); + removed_artifact_sources.extend(get_removed_full_sources( + compiler_state.full_sources.get(&project_name), + )); let dirty_artifact_paths = compiler_state .dirty_artifact_paths @@ -480,9 +484,25 @@ fn get_removed_docblock_artifact_source_keys( } } } + } + + removed_docblocks +} - removed_docblocks - } else { - vec![] +/// Get the list of removed full sources. +fn get_removed_full_sources(full_sources: Option<&FullSources>) -> Vec { + let mut removed_full_sources: Vec = vec![]; + if let Some(full_sources) = full_sources { + for (file, source) in full_sources.pending.iter() { + if source.is_empty() { + if let Some(text) = full_sources.processed.get(file) { + // For now, full sources are only used for ResolverHash + removed_full_sources.push(ArtifactSourceKey::ResolverHash( + ResolverSourceHash::new(text), + )) + } + } + } } + removed_full_sources } diff --git a/compiler/crates/relay-compiler/src/compiler_state.rs b/compiler/crates/relay-compiler/src/compiler_state.rs index ed1929332101d..3f8bdb8b5292f 100644 --- a/compiler/crates/relay-compiler/src/compiler_state.rs +++ b/compiler/crates/relay-compiler/src/compiler_state.rs @@ -419,6 +419,10 @@ impl CompilerState { .docblocks .get(&project_name) .map_or(false, |sources| !sources.pending.is_empty()) + || self + .full_sources + .get(&project_name) + .map_or(false, |sources| !sources.pending.is_empty()) } pub fn has_processed_changes(&self) -> bool {