Skip to content
Merged
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
3 changes: 0 additions & 3 deletions mordant-baseline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"tuple_wants_struct:src/css/values/color.rs" = 5

[bun_install]
"always_unwrapped_option:src/install/PackageInstall.rs" = 1
"arg_named_like_other_param:src/install/PackageManager/PackageJSONEditor.rs" = 3
"arg_named_like_other_param:src/install/resolution.rs" = 1
"bare_bool_args:src/install/isolated_install.rs" = 1
Expand Down Expand Up @@ -56,7 +55,6 @@
"arg_named_like_other_param:src/runtime/node/path.rs" = 2
"bare_bool_args:src/runtime/api.rs" = 2
"bare_bool_args:src/runtime/api/bun/h2_frame_parser.rs" = 1
"bare_bool_args:src/runtime/bake/dev_server/incremental_graph.rs" = 1
"bare_bool_args:src/runtime/cli/run_command.rs" = 1
"bare_bool_args:src/runtime/dns_jsc/dns.rs" = 1
"bare_bool_args:src/runtime/node/types.rs" = 4
Expand All @@ -69,7 +67,6 @@
"error_collapsed_to_bool:src/runtime/ffi/ffi_body.rs" = 1
"field_valid_only_when:src/runtime/cli/filter_run.rs" = 1
"field_valid_only_when:src/runtime/shell/builtin/rm.rs" = 1
"narrowed_two_ways:src/runtime/node/node_crypto_binding.rs" = 1
"parallel_vecs:src/runtime/api/html_rewriter.rs" = 1
"parallel_vecs:src/runtime/bake/dev_server/incremental_graph.rs" = 1
"reimplemented_helper:src/runtime/api/bun/Terminal.rs" = 1
Expand Down
31 changes: 19 additions & 12 deletions src/runtime/bake/DevServer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,9 @@ pub(crate) fn init(options: Options) -> JsResult<Box<DevServer>> {
// `debug_assert!` does not evaluate its argument in release. Hoist
// the side-effecting `insert_stale`
// out so the refresh runtime is registered at index 0 in all builds.
let idx = dev.client_graph.insert_stale(&rfr.import_source, false)?;
let idx = dev
.client_graph
.insert_stale(&rfr.import_source, bake::Graph::Client)?;
debug_assert!(idx == incremental_graph::FileIndex::<{ bake::Side::Client }>::init(0));
}

Expand Down Expand Up @@ -951,8 +953,8 @@ pub(crate) fn init(options: Options) -> JsResult<Box<DevServer>> {
// SAFETY: `server_graph` is disjoint from `framework`.
let server_file = unsafe { &mut (*dev_ptr).server_graph }.insert_stale_extra(
&fsr.entry_server,
false,
true,
bake::Graph::Server,
incremental_graph::RouteKind::Route,
)?;

types.push(framework_router::Type {
Expand All @@ -974,7 +976,8 @@ pub(crate) fn init(options: Options) -> JsResult<Box<DevServer>> {
client_file: if let Some(client) = &fsr.entry_client {
Some(to_opaque_file_id::<{ bake::Side::Client }>(
// SAFETY: `client_graph` is disjoint from `framework`.
unsafe { &mut (*dev_ptr).client_graph }.insert_stale(client, false)?,
unsafe { &mut (*dev_ptr).client_graph }
.insert_stale(client, bake::Graph::Client)?,
))
} else {
None
Expand Down Expand Up @@ -5000,12 +5003,10 @@ impl DevServer {
let _g = self.graph_safety_lock.guard();

let owner: serialized_failure::OwnerPacked = if graph == bake::Graph::Client {
let idx = self.client_graph.insert_stale(abs_path, false)?;
let idx = self.client_graph.insert_stale(abs_path, graph)?;
serialized_failure::OwnerPacked::new(bake::Side::Client, idx.get())
} else {
let idx = self
.server_graph
.insert_stale(abs_path, graph == bake::Graph::Ssr)?;
let idx = self.server_graph.insert_stale(abs_path, graph)?;
serialized_failure::OwnerPacked::new(bake::Side::Server, idx.get())
};
let current_bundle = self
Expand Down Expand Up @@ -5224,9 +5225,11 @@ impl DevServer {
// R-2: shared deref — only `bundle.path` is read; mutation of
// `dev_server_id` goes through the `Cell` `index_location` above.
let html_ref = unsafe { &*html };
let incremental_graph_index =
self.client_graph
.insert_stale_extra(&html_ref.bundle.path, false, true)?;
let incremental_graph_index = self.client_graph.insert_stale_extra(
&html_ref.bundle.path,
bake::Graph::Client,
incremental_graph::RouteKind::Route,
)?;
let file = &mut self.client_graph.bundled_files.values_mut()
[incremental_graph_index.get() as usize];
file.html_route_bundle_index = Some(bundle_index);
Expand Down Expand Up @@ -5847,7 +5850,11 @@ impl DevServer {
) -> crate::Result<OpaqueFileId> {
let index = self
.server_graph
.insert_stale_extra(abs_path, false, true)
.insert_stale_extra(
abs_path,
bake::Graph::Server,
incremental_graph::RouteKind::Route,
)
.map_err(crate::Error::from)?;
self.route_lookup.put(
index,
Expand Down
31 changes: 25 additions & 6 deletions src/runtime/bake/dev_server/incremental_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ enum FreeCssMode {
IgnoreCss,
}

/// Whether the file `insert_stale_extra` adds is a route. On the server this
/// sets `File::is_route`, which makes `trace_dependencies` look the file up in
/// `DevServer::route_lookup`, so callers passing `Route` must register it
/// there. The client graph ignores it; HTML routes are found through
/// `File::html_route_bundle_index`.
Comment thread
robobun marked this conversation as resolved.
Outdated
#[derive(Copy, Clone, Eq, PartialEq)]
pub(crate) enum RouteKind {
NotRoute,
Route,
}

#[derive(Copy, Clone)]
pub enum InsertFailureKey<'a> {
AbsPath(&'a [u8]),
Expand Down Expand Up @@ -1277,23 +1288,30 @@ impl<const SIDE: bake::Side> IncrementalGraph<SIDE> {
pub(crate) fn insert_stale(
&mut self,
abs_path: &[u8],
is_ssr_graph: bool,
graph: bake::Graph,
) -> Result<FileIndex<SIDE>, bun_alloc::AllocError> {
self.insert_stale_extra(abs_path, is_ssr_graph, false)
self.insert_stale_extra(abs_path, graph, RouteKind::NotRoute)
}

/// `IncrementalGraph(side).insertStaleExtra` (spec :1300).
///
/// `graph` is `Client` on the client graph; on the server graph it picks
/// which of the two server graphs (`Server` = RSC, `Ssr`) the file is in.
Comment thread
robobun marked this conversation as resolved.
Outdated
pub(crate) fn insert_stale_extra(
&mut self,
abs_path: &[u8],
is_ssr_graph: bool,
is_route: bool,
graph: bake::Graph,
route: RouteKind,
) -> Result<FileIndex<SIDE>, bun_alloc::AllocError> {
debug_assert!(match SIDE {
Side::Client => graph == bake::Graph::Client,
Side::Server => graph != bake::Graph::Client,
});
let gop = self.bundled_files.get_or_put(abs_path)?;
let idx = gop.index;
let found_existing = gop.found_existing;
if found_existing {
if matches!(SIDE, Side::Server) && is_route {
if matches!(SIDE, Side::Server) && route == RouteKind::Route {
gop.value_ptr.is_route = true;
}
} else {
Expand Down Expand Up @@ -1322,13 +1340,14 @@ impl<const SIDE: bake::Side> IncrementalGraph<SIDE> {
}
}
Side::Server => {
let is_ssr_graph = graph == bake::Graph::Ssr;
if !found_existing {
self.bundled_files.values_mut()[idx] = File {
kind: FileKind::Unknown,
failed: false,
is_rsc: !is_ssr_graph,
is_ssr: is_ssr_graph,
is_route,
is_route: route == RouteKind::Route,
is_client_component_boundary: false,
..Default::default()
};
Expand Down
Loading