Skip to content

Commit

Permalink
Turbopack: avoid sending serverComponentChanges with errors (#57425)
Browse files Browse the repository at this point in the history
We don't want to send the serverComponentChanges event until the
compilation is free of errors.

Closes WEB-1859
  • Loading branch information
sokra authored Oct 25, 2023
1 parent 8a4b0f1 commit dee316c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/next-swc/crates/napi/src/next_api/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}])
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dee316c

Please sign in to comment.