Skip to content

Commit 8c09f31

Browse files
committed
Revert "Turbopack: avoid dependencies due to tracing"
This reverts commit 26c3e2e.
1 parent 16bc145 commit 8c09f31

File tree

6 files changed

+23
-84
lines changed

6 files changed

+23
-84
lines changed

crates/next-api/src/nft_json.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,7 @@ pub async fn all_assets_from_entries_filtered(
408408
Ok((
409409
*asset,
410410
if emit_spans {
411-
// INVALIDATION: we don't need to invalidate the list of assets when
412-
// the span name changes
413-
Some(asset.path_string().untracked().await?)
411+
Some(asset.path().to_string().await?)
414412
} else {
415413
None
416414
},
@@ -500,9 +498,7 @@ async fn get_referenced_server_assets(
500498
Ok(Some((
501499
*asset,
502500
if emit_spans {
503-
// INVALIDATION: we don't need to invalidate the list of assets when the span
504-
// name changes
505-
Some(asset.path_string().untracked().await?)
501+
Some(asset.path().to_string().await?)
506502
} else {
507503
None
508504
},

crates/next-core/src/emit.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::Result;
22
use tracing::{Instrument, Level, Span};
33
use turbo_rcstr::RcStr;
44
use turbo_tasks::{
5-
FxIndexSet, ReadRef, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, Vc,
5+
FxIndexSet, ReadRef, ResolvedVc, TryFlatJoinIterExt, TryJoinIterExt, ValueToString, Vc,
66
graph::{AdjacencyMap, GraphTraversal, Visit, VisitControlFlow},
77
};
88
use turbo_tasks_fs::{FileSystemPath, rebase};
@@ -161,9 +161,7 @@ pub async fn all_assets_from_entries(entries: Vc<OutputAssets>) -> Result<Vc<Out
161161
Ok((
162162
*asset,
163163
if emit_spans {
164-
// INVALIDATION: we don't need to invalidate when the span name
165-
// changes
166-
Some(asset.path_string().untracked().await?)
164+
Some(asset.path().to_string().await?)
167165
} else {
168166
None
169167
},
@@ -197,9 +195,7 @@ async fn get_referenced_assets(
197195
Ok((
198196
*asset,
199197
if emit_spans {
200-
// INVALIDATION: we don't need to invalidate the list of assets when the span
201-
// name changes
202-
Some(asset.path_string().untracked().await?)
198+
Some(asset.path().to_string().await?)
203199
} else {
204200
None
205201
},

crates/next-core/src/next_client_reference/visit_client_reference.rs

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use std::future::Future;
33
use anyhow::Result;
44
use rustc_hash::FxHashSet;
55
use serde::{Deserialize, Serialize};
6-
use tracing::{Instrument, Level, Span};
6+
use tracing::Instrument;
77
use turbo_rcstr::RcStr;
88
use turbo_tasks::{
9-
FxIndexSet, NonLocalValue, ReadRef, ResolvedVc, TryJoinIterExt, Vc,
9+
FxIndexSet, NonLocalValue, ReadRef, ResolvedVc, TryJoinIterExt, ValueToString, Vc,
1010
debug::ValueDebugFormat,
1111
graph::{AdjacencyMap, GraphTraversal, Visit, VisitControlFlow},
1212
trace::TraceRawVcs,
@@ -121,23 +121,14 @@ pub async fn find_server_entries(
121121
include_traced: bool,
122122
) -> Result<Vc<ServerEntries>> {
123123
async move {
124-
let emit_spans = tracing::enabled!(Level::INFO);
125124
let graph = AdjacencyMap::new()
126125
.skip_duplicates()
127126
.visit(
128127
vec![FindServerEntriesNode::Internal(
129128
entry,
130-
if emit_spans {
131-
// INVALIDATION: we don't need to invalidate when the span name changes
132-
Some(entry.ident_string().untracked().await?)
133-
} else {
134-
None
135-
},
129+
entry.ident().to_string().await?,
136130
)],
137-
FindServerEntries {
138-
include_traced,
139-
emit_spans,
140-
},
131+
FindServerEntries { include_traced },
141132
)
142133
.await
143134
.completed()?
@@ -170,7 +161,6 @@ pub async fn find_server_entries(
170161
struct FindServerEntries {
171162
/// Whether to walk ChunkingType::Traced references
172163
include_traced: bool,
173-
emit_spans: bool,
174164
}
175165

176166
#[derive(
@@ -187,12 +177,9 @@ struct FindServerEntries {
187177
)]
188178
enum FindServerEntriesNode {
189179
ClientReference,
190-
ServerComponentEntry(
191-
ResolvedVc<NextServerComponentModule>,
192-
Option<ReadRef<RcStr>>,
193-
),
194-
ServerUtilEntry(ResolvedVc<NextServerUtilityModule>, Option<ReadRef<RcStr>>),
195-
Internal(ResolvedVc<Box<dyn Module>>, Option<ReadRef<RcStr>>),
180+
ServerComponentEntry(ResolvedVc<NextServerComponentModule>, ReadRef<RcStr>),
181+
ServerUtilEntry(ResolvedVc<NextServerUtilityModule>, ReadRef<RcStr>),
182+
Internal(ResolvedVc<Box<dyn Module>>, ReadRef<RcStr>),
196183
}
197184

198185
impl Visit<FindServerEntriesNode> for FindServerEntries {
@@ -221,7 +208,6 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
221208
FindServerEntriesNode::ServerUtilEntry(module, _) => Vc::upcast(**module),
222209
FindServerEntriesNode::ServerComponentEntry(module, _) => Vc::upcast(**module),
223210
};
224-
let emit_spans = self.emit_spans;
225211
async move {
226212
// Pass include_traced to reuse the same cached `primary_chunkable_referenced_modules`
227213
// task result, but the traced references will be filtered out again afterwards.
@@ -249,13 +235,7 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
249235
{
250236
return Ok(FindServerEntriesNode::ServerComponentEntry(
251237
server_component_asset,
252-
if emit_spans {
253-
// INVALIDATION: we don't need to invalidate when the span name
254-
// changes
255-
Some(server_component_asset.ident_string().untracked().await?)
256-
} else {
257-
None
258-
},
238+
server_component_asset.ident().to_string().await?,
259239
));
260240
}
261241

@@ -264,24 +244,13 @@ impl Visit<FindServerEntriesNode> for FindServerEntries {
264244
{
265245
return Ok(FindServerEntriesNode::ServerUtilEntry(
266246
server_util_module,
267-
if emit_spans {
268-
// INVALIDATION: we don't need to invalidate when the span name
269-
// changes
270-
Some(module.ident_string().untracked().await?)
271-
} else {
272-
None
273-
},
247+
module.ident().to_string().await?,
274248
));
275249
}
276250

277251
Ok(FindServerEntriesNode::Internal(
278252
*module,
279-
if emit_spans {
280-
// INVALIDATION: we don't need to invalidate when the span name changes
281-
Some(module.ident_string().untracked().await?)
282-
} else {
283-
None
284-
},
253+
module.ident().to_string().await?,
285254
))
286255
});
287256

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

294263
fn span(&mut self, node: &FindServerEntriesNode) -> tracing::Span {
295-
if !self.emit_spans {
296-
return Span::current();
297-
}
298264
match node {
299265
FindServerEntriesNode::ClientReference => {
300266
tracing::info_span!("client reference")
301267
}
302268
FindServerEntriesNode::Internal(_, name) => {
303-
tracing::info_span!("module", name = display(name.as_ref().unwrap()))
269+
tracing::info_span!("module", name = display(name))
304270
}
305271
FindServerEntriesNode::ServerUtilEntry(_, name) => {
306-
tracing::info_span!("server util", name = display(name.as_ref().unwrap()))
272+
tracing::info_span!("server util", name = display(name))
307273
}
308274
FindServerEntriesNode::ServerComponentEntry(_, name) => {
309-
tracing::info_span!("layout segment", name = display(name.as_ref().unwrap()))
275+
tracing::info_span!("layout segment", name = display(name))
310276
}
311277
}
312278
}

turbopack/crates/turbopack-core/src/module.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use turbo_rcstr::RcStr;
2-
use turbo_tasks::{ResolvedVc, TaskInput, ValueToString, Vc};
1+
use turbo_tasks::{ResolvedVc, TaskInput, Vc};
32

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

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

22-
/// The identifier of the [Module] as string. It's expected to be unique and capture
23-
/// all properties of the [Module].
24-
#[turbo_tasks::function]
25-
fn ident_string(self: Vc<Self>) -> Vc<RcStr> {
26-
self.ident().to_string()
27-
}
28-
2921
/// Other [Module]s or [OutputAsset]s referenced from this [Module].
3022
// TODO refactor to avoid returning [OutputAsset]s here
3123
#[turbo_tasks::function]

turbopack/crates/turbopack-core/src/module_graph/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,8 +1702,7 @@ impl SingleModuleGraphBuilderNode {
17021702
Ok(Self::Module {
17031703
module,
17041704
ident: if emit_spans {
1705-
// INVALIDATION: we don't need to invalidate when the span name changes
1706-
Some(ident.to_string().untracked().await?)
1705+
Some(ident.to_string().await?)
17071706
} else {
17081707
None
17091708
},
@@ -1719,15 +1718,13 @@ impl SingleModuleGraphBuilderNode {
17191718
ref_data,
17201719
source,
17211720
source_ident: if emit_spans {
1722-
// INVALIDATION: we don't need to invalidate when the span name changes
1723-
Some(source.ident_string().untracked().await?)
1721+
Some(source.ident().to_string().await?)
17241722
} else {
17251723
None
17261724
},
17271725
target,
17281726
target_ident: if emit_spans {
1729-
// INVALIDATION: we don't need to invalidate when the span name changes
1730-
Some(target.ident_string().untracked().await?)
1727+
Some(target.ident().to_string().await?)
17311728
} else {
17321729
None
17331730
},

turbopack/crates/turbopack-core/src/output.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use anyhow::Result;
2-
use turbo_rcstr::RcStr;
3-
use turbo_tasks::{FxIndexSet, ResolvedVc, ValueToString, Vc};
2+
use turbo_tasks::{FxIndexSet, ResolvedVc, Vc};
43
use turbo_tasks_fs::FileSystemPath;
54

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

20-
/// The identifier of the [OutputAsset] as string. It's expected to be unique and
21-
/// capture all properties of the [OutputAsset].
22-
#[turbo_tasks::function]
23-
async fn path_string(self: Vc<Self>) -> Result<Vc<RcStr>> {
24-
Ok(self.path().resolve().await?.to_string())
25-
}
26-
2719
/// Other references [OutputAsset]s from this [OutputAsset].
2820
#[turbo_tasks::function]
2921
fn references(self: Vc<Self>) -> Vc<OutputAssets> {

0 commit comments

Comments
 (0)