From dee316c40edffd3e430c172fcbc7245fbb803150 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 25 Oct 2023 11:41:01 -0700 Subject: [PATCH] Turbopack: avoid sending serverComponentChanges with errors (#57425) We don't want to send the serverComponentChanges event until the compilation is free of errors. Closes WEB-1859 --- .../next-swc/crates/napi/src/next_api/endpoint.rs | 13 +++++++------ .../server/lib/router-utils/setup-dev-bundler.ts | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/next-swc/crates/napi/src/next_api/endpoint.rs b/packages/next-swc/crates/napi/src/next_api/endpoint.rs index 83402eb6adaaa..7ab2365a2b1a7 100644 --- a/packages/next-swc/crates/napi/src/next_api/endpoint.rs +++ b/packages/next-swc/crates/napi/src/next_api/endpoint.rs @@ -123,16 +123,17 @@ pub fn endpoint_server_changed_subscribe( func, move || async move { let changed = endpoint.server_changed(); - // We don't capture issues and diagonistics here since we don't want to be - // notified when they change changed.strongly_consistent().await?; - Ok(()) + let issues = get_issues(changed).await?; + let diags = get_diagnostics(changed).await?; + Ok((issues, diags)) }, - |_| { + |ctx| { + let (issues, diags) = ctx.value; Ok(vec![TurbopackResult { result: (), - issues: vec![], - diagnostics: vec![], + issues: issues.iter().map(|i| NapiIssue::from(&**i)).collect(), + diagnostics: diags.iter().map(|d| NapiDiagnostic::from(d)).collect(), }]) }, ) diff --git a/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts b/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts index 0c5f08d05f7ce..a0af76a636b64 100644 --- a/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts +++ b/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts @@ -1492,6 +1492,11 @@ async function startWatcher(opts: SetupOpts) { ) changeSubscription(page, route.rscEndpoint, (_page, change) => { + if (change.issues.some((issue) => issue.severity === 'error')) { + // Ignore any updates that has errors + // There will be another update without errors eventually + return + } switch (change.type) { case ServerClientChangeType.Server: case ServerClientChangeType.Both: