Skip to content

Commit ae96d7b

Browse files
authored
[turbopack] Remove Value::new wrapper for ServerContextType parameters (vercel#80133)
Remove Value::new wrapper for ServerContextType parameters ### Why? The Value<> type is confusing and error prone, lets destroy it! As discussed over slack, turbo_tasks::Value type always implements is_resolved as true and is_transient as false which is incorrect and can enable smuggling transient vcs into turbo tasks. • https://vercel.slack.com/archives/C03EWR7LGEN/p1743456121241529https://vercel.slack.com/archives/C04NGV98TPS/p1743455453764879
1 parent f75598f commit ae96d7b

File tree

9 files changed

+74
-83
lines changed

9 files changed

+74
-83
lines changed

crates/next-api/src/app.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl AppProject {
237237
Ok(get_server_module_options_context(
238238
self.project().project_path(),
239239
self.project().execution_context(),
240-
Value::new(self.rsc_ty().owned().await?),
240+
self.rsc_ty().owned().await?,
241241
self.project().next_mode(),
242242
self.project().next_config(),
243243
NextRuntime::NodeJs,
@@ -250,7 +250,7 @@ impl AppProject {
250250
Ok(get_server_module_options_context(
251251
self.project().project_path(),
252252
self.project().execution_context(),
253-
Value::new(self.rsc_ty().owned().await?),
253+
self.rsc_ty().owned().await?,
254254
self.project().next_mode(),
255255
self.project().next_config(),
256256
NextRuntime::Edge,
@@ -263,7 +263,7 @@ impl AppProject {
263263
Ok(get_server_module_options_context(
264264
self.project().project_path(),
265265
self.project().execution_context(),
266-
Value::new(self.route_ty().owned().await?),
266+
self.route_ty().owned().await?,
267267
self.project().next_mode(),
268268
self.project().next_config(),
269269
NextRuntime::NodeJs,
@@ -276,7 +276,7 @@ impl AppProject {
276276
Ok(get_server_module_options_context(
277277
self.project().project_path(),
278278
self.project().execution_context(),
279-
Value::new(self.route_ty().owned().await?),
279+
self.route_ty().owned().await?,
280280
self.project().next_mode(),
281281
self.project().next_config(),
282282
NextRuntime::Edge,
@@ -288,7 +288,7 @@ impl AppProject {
288288
async fn rsc_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> {
289289
Ok(get_server_resolve_options_context(
290290
self.project().project_path(),
291-
Value::new(self.rsc_ty().owned().await?),
291+
self.rsc_ty().owned().await?,
292292
self.project().next_mode(),
293293
self.project().next_config(),
294294
self.project().execution_context(),
@@ -299,7 +299,7 @@ impl AppProject {
299299
async fn edge_rsc_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> {
300300
Ok(get_edge_resolve_options_context(
301301
self.project().project_path(),
302-
Value::new(self.rsc_ty().owned().await?),
302+
self.rsc_ty().owned().await?,
303303
self.project().next_mode(),
304304
self.project().next_config(),
305305
self.project().execution_context(),
@@ -310,7 +310,7 @@ impl AppProject {
310310
async fn route_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> {
311311
Ok(get_server_resolve_options_context(
312312
self.project().project_path(),
313-
Value::new(self.route_ty().owned().await?),
313+
self.route_ty().owned().await?,
314314
self.project().next_mode(),
315315
self.project().next_config(),
316316
self.project().execution_context(),
@@ -323,7 +323,7 @@ impl AppProject {
323323
) -> Result<Vc<ResolveOptionsContext>> {
324324
Ok(get_edge_resolve_options_context(
325325
self.project().project_path(),
326-
Value::new(self.route_ty().owned().await?),
326+
self.route_ty().owned().await?,
327327
self.project().next_mode(),
328328
self.project().next_config(),
329329
self.project().execution_context(),
@@ -587,7 +587,7 @@ impl AppProject {
587587
Ok(get_server_module_options_context(
588588
self.project().project_path(),
589589
self.project().execution_context(),
590-
Value::new(self.ssr_ty().owned().await?),
590+
self.ssr_ty().owned().await?,
591591
self.project().next_mode(),
592592
self.project().next_config(),
593593
NextRuntime::NodeJs,
@@ -600,7 +600,7 @@ impl AppProject {
600600
Ok(get_server_module_options_context(
601601
self.project().project_path(),
602602
self.project().execution_context(),
603-
Value::new(self.ssr_ty().owned().await?),
603+
self.ssr_ty().owned().await?,
604604
self.project().next_mode(),
605605
self.project().next_config(),
606606
NextRuntime::Edge,
@@ -612,7 +612,7 @@ impl AppProject {
612612
async fn ssr_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> {
613613
Ok(get_server_resolve_options_context(
614614
self.project().project_path(),
615-
Value::new(self.ssr_ty().owned().await?),
615+
self.ssr_ty().owned().await?,
616616
self.project().next_mode(),
617617
self.project().next_config(),
618618
self.project().execution_context(),
@@ -623,7 +623,7 @@ impl AppProject {
623623
async fn edge_ssr_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> {
624624
Ok(get_edge_resolve_options_context(
625625
self.project().project_path(),
626-
Value::new(self.ssr_ty().owned().await?),
626+
self.ssr_ty().owned().await?,
627627
self.project().next_mode(),
628628
self.project().next_config(),
629629
self.project().execution_context(),
@@ -755,7 +755,7 @@ impl AppProject {
755755
#[turbo_tasks::function]
756756
async fn runtime_entries(self: Vc<Self>) -> Result<Vc<RuntimeEntries>> {
757757
Ok(get_server_runtime_entries(
758-
Value::new(self.rsc_ty().owned().await?),
758+
self.rsc_ty().owned().await?,
759759
self.project().next_mode(),
760760
))
761761
}

crates/next-api/src/instrumentation.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use next_core::{
77
};
88
use tracing::Instrument;
99
use turbo_rcstr::{RcStr, rcstr};
10-
use turbo_tasks::{Completion, ResolvedVc, Value, Vc};
10+
use turbo_tasks::{Completion, ResolvedVc, Vc};
1111
use turbo_tasks_fs::{File, FileContent, FileSystemPath};
1212
use turbopack_core::{
1313
asset::AssetContent,
@@ -105,12 +105,12 @@ impl InstrumentationEndpoint {
105105
let module_graph = this.project.module_graph(*module);
106106

107107
let evaluatable_assets = get_server_runtime_entries(
108-
Value::new(ServerContextType::Instrumentation {
108+
ServerContextType::Instrumentation {
109109
app_dir: this.app_dir,
110110
ecmascript_client_reference_transition_name: this
111111
.ecmascript_client_reference_transition_name
112112
.clone(),
113-
}),
113+
},
114114
this.project.next_mode(),
115115
)
116116
.resolve_entries(*this.asset_context)
@@ -150,12 +150,12 @@ impl InstrumentationEndpoint {
150150
.node_root()
151151
.join(rcstr!("server/instrumentation.js")),
152152
get_server_runtime_entries(
153-
Value::new(ServerContextType::Instrumentation {
153+
ServerContextType::Instrumentation {
154154
app_dir: this.app_dir,
155155
ecmascript_client_reference_transition_name: this
156156
.ecmascript_client_reference_transition_name
157157
.clone(),
158-
}),
158+
},
159159
this.project.next_mode(),
160160
)
161161
.resolve_entries(*this.asset_context)

crates/next-api/src/middleware.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use next_core::{
1111
};
1212
use tracing::Instrument;
1313
use turbo_rcstr::{RcStr, rcstr};
14-
use turbo_tasks::{Completion, ResolvedVc, Value, Vc};
14+
use turbo_tasks::{Completion, ResolvedVc, Vc};
1515
use turbo_tasks_fs::{self, File, FileContent, FileSystemPath};
1616
use turbopack_core::{
1717
asset::AssetContent,
@@ -107,12 +107,12 @@ impl MiddlewareEndpoint {
107107
let module_graph = this.project.module_graph(*module);
108108

109109
let evaluatable_assets = get_server_runtime_entries(
110-
Value::new(ServerContextType::Middleware {
110+
ServerContextType::Middleware {
111111
app_dir: this.app_dir,
112112
ecmascript_client_reference_transition_name: this
113113
.ecmascript_client_reference_transition_name
114114
.clone(),
115-
}),
115+
},
116116
this.project.next_mode(),
117117
)
118118
.resolve_entries(*this.asset_context)
@@ -151,12 +151,12 @@ impl MiddlewareEndpoint {
151151
.node_root()
152152
.join(rcstr!("server/middleware.js")),
153153
get_server_runtime_entries(
154-
Value::new(ServerContextType::Middleware {
154+
ServerContextType::Middleware {
155155
app_dir: this.app_dir,
156156
ecmascript_client_reference_transition_name: this
157157
.ecmascript_client_reference_transition_name
158158
.clone(),
159-
}),
159+
},
160160
this.project.next_mode(),
161161
)
162162
.resolve_entries(*this.asset_context)

crates/next-api/src/pages.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,9 @@ impl PagesProject {
443443
Ok(get_server_module_options_context(
444444
self.project().project_path(),
445445
self.project().execution_context(),
446-
Value::new(ServerContextType::Pages {
446+
ServerContextType::Pages {
447447
pages_dir: self.pages_dir().to_resolved().await?,
448-
}),
448+
},
449449
self.project().next_mode(),
450450
self.project().next_config(),
451451
NextRuntime::NodeJs,
@@ -458,9 +458,9 @@ impl PagesProject {
458458
Ok(get_server_module_options_context(
459459
self.project().project_path(),
460460
self.project().execution_context(),
461-
Value::new(ServerContextType::Pages {
461+
ServerContextType::Pages {
462462
pages_dir: self.pages_dir().to_resolved().await?,
463-
}),
463+
},
464464
self.project().next_mode(),
465465
self.project().next_config(),
466466
NextRuntime::Edge,
@@ -473,9 +473,9 @@ impl PagesProject {
473473
Ok(get_server_module_options_context(
474474
self.project().project_path(),
475475
self.project().execution_context(),
476-
Value::new(ServerContextType::PagesApi {
476+
ServerContextType::PagesApi {
477477
pages_dir: self.pages_dir().to_resolved().await?,
478-
}),
478+
},
479479
self.project().next_mode(),
480480
self.project().next_config(),
481481
NextRuntime::NodeJs,
@@ -488,9 +488,9 @@ impl PagesProject {
488488
Ok(get_server_module_options_context(
489489
self.project().project_path(),
490490
self.project().execution_context(),
491-
Value::new(ServerContextType::PagesApi {
491+
ServerContextType::PagesApi {
492492
pages_dir: self.pages_dir().to_resolved().await?,
493-
}),
493+
},
494494
self.project().next_mode(),
495495
self.project().next_config(),
496496
NextRuntime::Edge,
@@ -503,9 +503,9 @@ impl PagesProject {
503503
Ok(get_server_module_options_context(
504504
self.project().project_path(),
505505
self.project().execution_context(),
506-
Value::new(ServerContextType::PagesData {
506+
ServerContextType::PagesData {
507507
pages_dir: self.pages_dir().to_resolved().await?,
508-
}),
508+
},
509509
self.project().next_mode(),
510510
self.project().next_config(),
511511
NextRuntime::NodeJs,
@@ -520,9 +520,9 @@ impl PagesProject {
520520
Ok(get_server_module_options_context(
521521
self.project().project_path(),
522522
self.project().execution_context(),
523-
Value::new(ServerContextType::PagesData {
523+
ServerContextType::PagesData {
524524
pages_dir: self.pages_dir().to_resolved().await?,
525-
}),
525+
},
526526
self.project().next_mode(),
527527
self.project().next_config(),
528528
NextRuntime::Edge,
@@ -537,9 +537,9 @@ impl PagesProject {
537537
// NOTE(alexkirsz) This could be `PagesData` for the data endpoint, but it doesn't
538538
// matter (for now at least) because `get_server_resolve_options_context` doesn't
539539
// differentiate between the two.
540-
Value::new(ServerContextType::Pages {
540+
ServerContextType::Pages {
541541
pages_dir: self.pages_dir().to_resolved().await?,
542-
}),
542+
},
543543
self.project().next_mode(),
544544
self.project().next_config(),
545545
self.project().execution_context(),
@@ -553,9 +553,9 @@ impl PagesProject {
553553
// NOTE(alexkirsz) This could be `PagesData` for the data endpoint, but it doesn't
554554
// matter (for now at least) because `get_server_resolve_options_context` doesn't
555555
// differentiate between the two.
556-
Value::new(ServerContextType::Pages {
556+
ServerContextType::Pages {
557557
pages_dir: self.pages_dir().to_resolved().await?,
558-
}),
558+
},
559559
self.project().next_mode(),
560560
self.project().next_config(),
561561
self.project().execution_context(),
@@ -579,19 +579,19 @@ impl PagesProject {
579579
#[turbo_tasks::function]
580580
async fn runtime_entries(self: Vc<Self>) -> Result<Vc<RuntimeEntries>> {
581581
Ok(get_server_runtime_entries(
582-
Value::new(ServerContextType::Pages {
582+
ServerContextType::Pages {
583583
pages_dir: self.pages_dir().to_resolved().await?,
584-
}),
584+
},
585585
self.project().next_mode(),
586586
))
587587
}
588588

589589
#[turbo_tasks::function]
590590
async fn data_runtime_entries(self: Vc<Self>) -> Result<Vc<RuntimeEntries>> {
591591
Ok(get_server_runtime_entries(
592-
Value::new(ServerContextType::PagesData {
592+
ServerContextType::PagesData {
593593
pages_dir: self.pages_dir().to_resolved().await?,
594-
}),
594+
},
595595
self.project().next_mode(),
596596
))
597597
}

0 commit comments

Comments
 (0)