Unverified Commit 8589a6da authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Next build: use exported `handle_issues` from turbopack (#52972)

Note: depends on next Turbopack publish

https://github.com/vercel/turbo/pull/5487 exports a reusable `handle_issues` function for reporting issues and erroring when failing issues are encountered.

This uses it for `next build` with a failing severity level of error.
parent 4f7fc05f
......@@ -4,7 +4,7 @@ use std::{
path::{PathBuf, MAIN_SEPARATOR},
};
use anyhow::{anyhow, Context, Result};
use anyhow::{Context, Result};
use dunce::canonicalize;
use next_core::{
mode::NextMode,
......@@ -25,7 +25,7 @@ use next_core::{
use serde::Serialize;
use turbo_tasks::{
graph::{AdjacencyMap, GraphTraversal},
Completion, Completions, TransientInstance, TransientValue, TryJoinIterExt, Vc,
Completion, Completions, TransientInstance, TryJoinIterExt, Vc,
};
use turbopack_binding::{
turbo::tasks_fs::{rebase, DiskFileSystem, FileContent, FileSystem, FileSystemPath},
......@@ -35,7 +35,7 @@ use turbopack_binding::{
asset::Asset,
chunk::ChunkingContext,
environment::ServerAddr,
issue::{IssueDescriptionExt, IssueReporter, IssueSeverity},
issue::{handle_issues, IssueReporter, IssueSeverity},
output::{OutputAsset, OutputAssets},
virtual_fs::VirtualFileSystem,
},
......@@ -53,6 +53,9 @@ use crate::{
next_pages::page_entries::{compute_page_entries_chunks, get_page_entries},
};
// TODO this should be Error, but we need to fix the errors happening first
static MIN_FAILING_SEVERITY: IssueSeverity = IssueSeverity::Fatal;
#[turbo_tasks::function]
pub(crate) async fn next_build(options: TransientInstance<BuildOptions>) -> Result<Vc<Completion>> {
let project_root = options
......@@ -149,8 +152,22 @@ pub(crate) async fn next_build(options: TransientInstance<BuildOptions>) -> Resu
next_config,
);
handle_issues(page_entries, issue_reporter).await?;
handle_issues(app_entries, issue_reporter).await?;
handle_issues(
page_entries,
issue_reporter,
MIN_FAILING_SEVERITY.cell(),
None,
None,
)
.await?;
handle_issues(
app_entries,
issue_reporter,
MIN_FAILING_SEVERITY.cell(),
None,
None,
)
.await?;
let page_entries = page_entries.await?;
let app_entries = app_entries.await?;
......@@ -436,7 +453,14 @@ async fn workspace_fs(
issue_reporter: Vc<Box<dyn IssueReporter>>,
) -> Result<Vc<Box<dyn FileSystem>>> {
let disk_fs = DiskFileSystem::new("workspace".to_string(), workspace_root.to_string());
handle_issues(disk_fs, issue_reporter).await?;
handle_issues(
disk_fs,
issue_reporter,
MIN_FAILING_SEVERITY.cell(),
None,
None,
)
.await?;
Ok(Vc::upcast(disk_fs))
}
......@@ -446,7 +470,14 @@ async fn node_fs(
issue_reporter: Vc<Box<dyn IssueReporter>>,
) -> Result<Vc<Box<dyn FileSystem>>> {
let disk_fs = DiskFileSystem::new("node".to_string(), node_root.to_string());
handle_issues(disk_fs, issue_reporter).await?;
handle_issues(
disk_fs,
issue_reporter,
MIN_FAILING_SEVERITY.cell(),
None,
None,
)
.await?;
Ok(Vc::upcast(disk_fs))
}
......@@ -456,31 +487,17 @@ async fn client_fs(
issue_reporter: Vc<Box<dyn IssueReporter>>,
) -> Result<Vc<Box<dyn FileSystem>>> {
let disk_fs = DiskFileSystem::new("client".to_string(), client_root.to_string());
handle_issues(disk_fs, issue_reporter).await?;
handle_issues(
disk_fs,
issue_reporter,
MIN_FAILING_SEVERITY.cell(),
None,
None,
)
.await?;
Ok(Vc::upcast(disk_fs))
}
async fn handle_issues<T>(source: Vc<T>, issue_reporter: Vc<Box<dyn IssueReporter>>) -> Result<()> {
let issues = source
.peek_issues_with_path()
.await?
.strongly_consistent()
.await?;
let has_fatal = issue_reporter.report_issues(
TransientInstance::new(issues.clone()),
TransientValue::new(Vc::into_raw(source)),
// TODO this should be Error, but we need to fix the errors happing first
IssueSeverity::Fatal.cell(),
);
if *has_fatal.await? {
Err(anyhow!("Fatal issue(s) occurred"))
} else {
Ok(())
}
}
/// Emits all assets transitively reachable from the given chunks, that are
/// inside the node root or the client root.
async fn emit_all_assets(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment