Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions crates/next-api/src/nft_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,7 @@ pub async fn all_assets_from_entries_filtered(
Ok((
*asset,
if emit_spans {
// INVALIDATION: we don't need to invalidate the list of assets when
// the span name changes
Some(asset.path_string().untracked().await?)
Some(asset.path().to_string().await?)
} else {
None
},
Expand Down Expand Up @@ -500,9 +498,7 @@ async fn get_referenced_server_assets(
Ok(Some((
*asset,
if emit_spans {
// INVALIDATION: we don't need to invalidate the list of assets when the span
// name changes
Some(asset.path_string().untracked().await?)
Some(asset.path().to_string().await?)
} else {
None
},
Expand Down
10 changes: 3 additions & 7 deletions crates/next-core/src/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use tracing::{Instrument, Level, Span};
use turbo_rcstr::RcStr;
use turbo_tasks::{
FxIndexSet, ReadRef, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc,
FxIndexSet, ReadRef, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueToString, Vc,
graph::{AdjacencyMap, GraphTraversal, Visit, VisitControlFlow},
};
use turbo_tasks_fs::{FileSystemPath, rebase};
Expand Down Expand Up @@ -161,9 +161,7 @@ pub async fn all_assets_from_entries(entries: Vc<OutputAssets>) -> Result<Vc<Out
Ok((
*asset,
if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name
// changes
Some(asset.path_string().untracked().await?)
Some(asset.path().to_string().await?)
} else {
None
},
Expand Down Expand Up @@ -197,9 +195,7 @@ async fn get_referenced_assets(
Ok((
*asset,
if emit_spans {
// INVALIDATION: we don't need to invalidate the list of assets when the span
// name changes
Some(asset.path_string().untracked().await?)
Some(asset.path().to_string().await?)
} else {
None
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::future::Future;
use anyhow::Result;
use rustc_hash::FxHashSet;
use serde::{Deserialize, Serialize};
use tracing::{Instrument, Level, Span};
use tracing::Instrument;
use turbo_rcstr::RcStr;
use turbo_tasks::{
FxIndexSet, NonLocalValue, ReadRef, ResolvedVc, TryJoinIterExt, Vc,
FxIndexSet, NonLocalValue, ReadRef, ResolvedVc, TryJoinIterExt, ValueToString, Vc,
debug::ValueDebugFormat,
graph::{AdjacencyMap, GraphTraversal, Visit, VisitControlFlow},
trace::TraceRawVcs,
Expand Down Expand Up @@ -121,23 +121,14 @@ pub async fn find_server_entries(
include_traced: bool,
) -> Result<Vc<ServerEntries>> {
async move {
let emit_spans = tracing::enabled!(Level::INFO);
let graph = AdjacencyMap::new()
.skip_duplicates()
.visit(
vec![FindServerEntriesNode::Internal(
entry,
if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name changes
Some(entry.ident_string().untracked().await?)
} else {
None
},
entry.ident().to_string().await?,
)],
FindServerEntries {
include_traced,
emit_spans,
},
FindServerEntries { include_traced },
)
.await
.completed()?
Expand Down Expand Up @@ -170,7 +161,6 @@ pub async fn find_server_entries(
struct FindServerEntries {
/// Whether to walk ChunkingType::Traced references
include_traced: bool,
emit_spans: bool,
}

#[derive(
Expand All @@ -187,12 +177,9 @@ struct FindServerEntries {
)]
enum FindServerEntriesNode {
ClientReference,
ServerComponentEntry(
ResolvedVc<NextServerComponentModule>,
Option<ReadRef<RcStr>>,
),
ServerUtilEntry(ResolvedVc<NextServerUtilityModule>, Option<ReadRef<RcStr>>),
Internal(ResolvedVc<Box<dyn Module>>, Option<ReadRef<RcStr>>),
ServerComponentEntry(ResolvedVc<NextServerComponentModule>, ReadRef<RcStr>),
ServerUtilEntry(ResolvedVc<NextServerUtilityModule>, ReadRef<RcStr>),
Internal(ResolvedVc<Box<dyn Module>>, ReadRef<RcStr>),
}

impl Visit<FindServerEntriesNode> for FindServerEntries {
Expand Down Expand Up @@ -221,7 +208,6 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
FindServerEntriesNode::ServerUtilEntry(module, _) => Vc::upcast(**module),
FindServerEntriesNode::ServerComponentEntry(module, _) => Vc::upcast(**module),
};
let emit_spans = self.emit_spans;
async move {
// Pass include_traced to reuse the same cached `primary_chunkable_referenced_modules`
// task result, but the traced references will be filtered out again afterwards.
Expand Down Expand Up @@ -249,13 +235,7 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
{
return Ok(FindServerEntriesNode::ServerComponentEntry(
server_component_asset,
if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name
// changes
Some(server_component_asset.ident_string().untracked().await?)
} else {
None
},
server_component_asset.ident().to_string().await?,
));
}

Expand All @@ -264,24 +244,13 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
{
return Ok(FindServerEntriesNode::ServerUtilEntry(
server_util_module,
if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name
// changes
Some(module.ident_string().untracked().await?)
} else {
None
},
module.ident().to_string().await?,
));
}

Ok(FindServerEntriesNode::Internal(
*module,
if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name changes
Some(module.ident_string().untracked().await?)
} else {
None
},
module.ident().to_string().await?,
))
});

Expand All @@ -292,21 +261,18 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
}

fn span(&mut self, node: &FindServerEntriesNode) -> tracing::Span {
if !self.emit_spans {
return Span::current();
}
match node {
FindServerEntriesNode::ClientReference => {
tracing::info_span!("client reference")
}
FindServerEntriesNode::Internal(_, name) => {
tracing::info_span!("module", name = display(name.as_ref().unwrap()))
tracing::info_span!("module", name = display(name))
}
FindServerEntriesNode::ServerUtilEntry(_, name) => {
tracing::info_span!("server util", name = display(name.as_ref().unwrap()))
tracing::info_span!("server util", name = display(name))
}
FindServerEntriesNode::ServerComponentEntry(_, name) => {
tracing::info_span!("layout segment", name = display(name.as_ref().unwrap()))
tracing::info_span!("layout segment", name = display(name))
}
}
}
Expand Down
10 changes: 1 addition & 9 deletions turbopack/crates/turbopack-core/src/module.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use turbo_rcstr::RcStr;
use turbo_tasks::{ResolvedVc, TaskInput, ValueToString, Vc};
use turbo_tasks::{ResolvedVc, TaskInput, Vc};

use crate::{asset::Asset, ident::AssetIdent, reference::ModuleReferences};

Expand All @@ -19,13 +18,6 @@ pub trait Module: Asset {
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent>;

/// The identifier of the [Module] as string. It's expected to be unique and capture
/// all properties of the [Module].
#[turbo_tasks::function]
fn ident_string(self: Vc<Self>) -> Vc<RcStr> {
self.ident().to_string()
}

/// Other [Module]s or [OutputAsset]s referenced from this [Module].
// TODO refactor to avoid returning [OutputAsset]s here
#[turbo_tasks::function]
Expand Down
9 changes: 3 additions & 6 deletions turbopack/crates/turbopack-core/src/module_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1702,8 +1702,7 @@ impl SingleModuleGraphBuilderNode {
Ok(Self::Module {
module,
ident: if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name changes
Some(ident.to_string().untracked().await?)
Some(ident.to_string().await?)
} else {
None
},
Expand All @@ -1719,15 +1718,13 @@ impl SingleModuleGraphBuilderNode {
ref_data,
source,
source_ident: if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name changes
Some(source.ident_string().untracked().await?)
Some(source.ident().to_string().await?)
} else {
None
},
target,
target_ident: if emit_spans {
// INVALIDATION: we don't need to invalidate when the span name changes
Some(target.ident_string().untracked().await?)
Some(target.ident().to_string().await?)
} else {
None
},
Expand Down
10 changes: 1 addition & 9 deletions turbopack/crates/turbopack-core/src/output.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexSet, ResolvedVc, ValueToString, Vc};
use turbo_tasks::{FxIndexSet, ResolvedVc, Vc};
use turbo_tasks_fs::FileSystemPath;

use crate::asset::Asset;
Expand All @@ -17,13 +16,6 @@ pub trait OutputAsset: Asset {
#[turbo_tasks::function]
fn path(&self) -> Vc<FileSystemPath>;

/// The identifier of the [OutputAsset] as string. It's expected to be unique and
/// capture all properties of the [OutputAsset].
#[turbo_tasks::function]
async fn path_string(self: Vc<Self>) -> Result<Vc<RcStr>> {
Ok(self.path().resolve().await?.to_string())
}

/// Other references [OutputAsset]s from this [OutputAsset].
#[turbo_tasks::function]
fn references(self: Vc<Self>) -> Vc<OutputAssets> {
Expand Down
Loading