Skip to content

Commit

Permalink
move apply_effects outside of the inner task
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Nov 15, 2024
1 parent 8bd62c3 commit 201c9f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
15 changes: 8 additions & 7 deletions crates/napi/src/next_api/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ async fn strongly_consistent_catch_collectables<R: VcValueType + Send>(
Arc<Vec<ReadRef<PlainDiagnostic>>>,
)> {
let result = source.strongly_consistent().await;
apply_effects(source).await?;
let issues = get_issues(source).await?;
let diagnostics = get_diagnostics(source).await?;

Expand Down Expand Up @@ -150,13 +149,14 @@ pub async fn endpoint_write_to_disk(
let endpoint = ***endpoint;
let (written, issues, diags) = turbo_tasks
.run_once(async move {
let operation = get_written_endpoint_with_issues(endpoint);
let WrittenEndpointWithIssues {
written,
issues,
diagnostics,
} = &*get_written_endpoint_with_issues(endpoint)
.strongly_consistent()
.await?;
} = &*operation.strongly_consistent().await?;
apply_effects(operation).await?;

Ok((written.clone(), issues.clone(), diagnostics.clone()))
})
.await
Expand All @@ -181,9 +181,10 @@ pub fn endpoint_server_changed_subscribe(
func,
move || {
async move {
subscribe_issues_and_diags(endpoint, issues)
.strongly_consistent()
.await
let operation = subscribe_issues_and_diags(endpoint, issues);
let result = operation.strongly_consistent().await?;
apply_effects(operation).await?;
Ok(result)
}
.instrument(tracing::info_span!("server changes subscription"))
},
Expand Down
21 changes: 9 additions & 12 deletions crates/napi/src/next_api/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,6 @@ async fn get_entrypoints_with_issues(
) -> Result<Vc<EntrypointsWithIssues>> {
let entrypoints_operation = container.entrypoints();
let entrypoints = entrypoints_operation.strongly_consistent().await?;
apply_effects(entrypoints_operation).await?;
let issues = get_issues(entrypoints_operation).await?;
let diagnostics = get_diagnostics(entrypoints_operation).await?;
Ok(EntrypointsWithIssues {
Expand All @@ -653,13 +652,13 @@ pub fn project_entrypoints_subscribe(
func,
move || {
async move {
let operation = get_entrypoints_with_issues(container);
let EntrypointsWithIssues {
entrypoints,
issues,
diagnostics,
} = &*get_entrypoints_with_issues(container)
.strongly_consistent()
.await?;
} = &*operation.strongly_consistent().await?;
apply_effects(operation).await?;
Ok((entrypoints.clone(), issues.clone(), diagnostics.clone()))
}
.instrument(tracing::info_span!("entrypoints subscription"))
Expand Down Expand Up @@ -728,7 +727,6 @@ async fn hmr_update(
) -> Result<Vc<HmrUpdateWithIssues>> {
let update_operation = project.hmr_update(identifier, state);
let update = update_operation.strongly_consistent().await?;
apply_effects(update_operation).await?;
let issues = get_issues(update_operation).await?;
let diagnostics = get_diagnostics(update_operation).await?;
Ok(HmrUpdateWithIssues {
Expand Down Expand Up @@ -761,9 +759,9 @@ pub fn project_hmr_events(
let project = project.project().resolve().await?;
let state = project.hmr_version_state(identifier.clone(), session);

let update = hmr_update(project, identifier.clone(), state)
.strongly_consistent()
.await?;
let operation = hmr_update(project, identifier.clone(), state);
let update = operation.strongly_consistent().await?;
apply_effects(operation).await?;
let HmrUpdateWithIssues {
update,
issues,
Expand Down Expand Up @@ -841,7 +839,6 @@ async fn get_hmr_identifiers_with_issues(
) -> Result<Vc<HmrIdentifiersWithIssues>> {
let hmr_identifiers_operation = container.hmr_identifiers();
let hmr_identifiers = hmr_identifiers_operation.strongly_consistent().await?;
apply_effects(hmr_identifiers_operation).await?;
let issues = get_issues(hmr_identifiers_operation).await?;
let diagnostics = get_diagnostics(hmr_identifiers_operation).await?;
Ok(HmrIdentifiersWithIssues {
Expand All @@ -863,13 +860,13 @@ pub fn project_hmr_identifiers_subscribe(
turbo_tasks.clone(),
func,
move || async move {
let operation = get_hmr_identifiers_with_issues(container);
let HmrIdentifiersWithIssues {
identifiers,
issues,
diagnostics,
} = &*get_hmr_identifiers_with_issues(container)
.strongly_consistent()
.await?;
} = &*operation.strongly_consistent().await?;
apply_effects(operation).await?;

Ok((identifiers.clone(), issues.clone(), diagnostics.clone()))
},
Expand Down

0 comments on commit 201c9f3

Please sign in to comment.