More fullstack fixes (#4737)
* allow `--server` only builds! * rollback example * capture `/:route` routes * fix: properly implement file uploads in forms * implement desktop form uploads * Performant serialization of form bytes * finish up file stuff * cleanups * add request headers to streaming context * remove some unwraps
This commit is contained in:
1 parent
fc01a002fd
commit
92792aded9
47 files changed
+1241
-703
No files matched your search
@@ -109,12 +109,12 @@ pub(crate) async fn serve_all(args: ServeArgs, tracer: &TraceController) -> Resu
|
||||
pid,
|
||||
} => {
|
||||
devserver
|
||||
.send_hotreload(builder.applied_hot_reload_changes(BuildId::CLIENT))
|
||||
.send_hotreload(builder.applied_hot_reload_changes(BuildId::PRIMARY))
|
||||
.await;
|
||||
|
||||
if builder.server.is_some() {
|
||||
devserver
|
||||
.send_hotreload(builder.applied_hot_reload_changes(BuildId::SERVER))
|
||||
.send_hotreload(builder.applied_hot_reload_changes(BuildId::SECONDARY))
|
||||
.await;
|
||||
}
|
||||
|
||||
|
||||
@@ -268,12 +268,12 @@ impl Output {
|
||||
}
|
||||
KeyCode::Char('D') => {
|
||||
return Ok(Some(ServeUpdate::OpenDebugger {
|
||||
id: BuildId::SERVER,
|
||||
id: BuildId::SECONDARY,
|
||||
}));
|
||||
}
|
||||
KeyCode::Char('d') => {
|
||||
return Ok(Some(ServeUpdate::OpenDebugger {
|
||||
id: BuildId::CLIENT,
|
||||
id: BuildId::PRIMARY,
|
||||
}));
|
||||
}
|
||||
KeyCode::Char('c') => {
|
||||
|
||||
@@ -234,9 +234,9 @@ impl AppServer {
|
||||
false => BuildMode::Base { run: true },
|
||||
};
|
||||
|
||||
self.client.start(build_mode.clone());
|
||||
self.client.start(build_mode.clone(), BuildId::PRIMARY);
|
||||
if let Some(server) = self.server.as_mut() {
|
||||
server.start(build_mode);
|
||||
server.start(build_mode, BuildId::SECONDARY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,14 +273,14 @@ impl AppServer {
|
||||
// Wait for the client to finish
|
||||
client_update = client_wait => {
|
||||
ServeUpdate::BuilderUpdate {
|
||||
id: BuildId::CLIENT,
|
||||
id: BuildId::PRIMARY,
|
||||
update: client_update,
|
||||
}
|
||||
}
|
||||
|
||||
Some(server_update) = server_wait => {
|
||||
ServeUpdate::BuilderUpdate {
|
||||
id: BuildId::SERVER,
|
||||
id: BuildId::SECONDARY,
|
||||
update: server_update,
|
||||
}
|
||||
}
|
||||
@@ -491,17 +491,18 @@ impl AppServer {
|
||||
// A full rebuild is required when the user modifies static initializers which we haven't wired up yet.
|
||||
if needs_full_rebuild && self.automatic_rebuilds {
|
||||
if self.use_hotpatch_engine {
|
||||
self.client.patch_rebuild(files.to_vec());
|
||||
self.client.patch_rebuild(files.to_vec(), BuildId::PRIMARY);
|
||||
if let Some(server) = self.server.as_mut() {
|
||||
server.patch_rebuild(files.to_vec());
|
||||
server.patch_rebuild(files.to_vec(), BuildId::SECONDARY);
|
||||
}
|
||||
self.clear_hot_reload_changes();
|
||||
self.clear_cached_rsx();
|
||||
server.send_patch_start().await;
|
||||
} else {
|
||||
self.client.start_rebuild(BuildMode::Base { run: true });
|
||||
self.client
|
||||
.start_rebuild(BuildMode::Base { run: true }, BuildId::PRIMARY);
|
||||
if let Some(server) = self.server.as_mut() {
|
||||
server.start_rebuild(BuildMode::Base { run: true });
|
||||
server.start_rebuild(BuildMode::Base { run: true }, BuildId::SECONDARY);
|
||||
}
|
||||
self.clear_hot_reload_changes();
|
||||
self.clear_cached_rsx();
|
||||
@@ -560,13 +561,14 @@ impl AppServer {
|
||||
devserver: &mut WebServer,
|
||||
) -> Result<()> {
|
||||
// Make sure to save artifacts regardless of if we're opening the app or not
|
||||
match artifacts.bundle {
|
||||
BundleFormat::Server => {
|
||||
match artifacts.build_id {
|
||||
BuildId::PRIMARY => self.client.artifacts = Some(artifacts.clone()),
|
||||
BuildId::SECONDARY => {
|
||||
if let Some(server) = self.server.as_mut() {
|
||||
server.artifacts = Some(artifacts.clone());
|
||||
}
|
||||
}
|
||||
_ => self.client.artifacts = Some(artifacts.clone()),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let should_open = self.client.stage == BuildStage::Success
|
||||
@@ -634,7 +636,7 @@ impl AppServer {
|
||||
fullstack_address,
|
||||
false,
|
||||
false,
|
||||
BuildId::SERVER,
|
||||
BuildId::SECONDARY,
|
||||
&self.server_args,
|
||||
)
|
||||
.await?;
|
||||
@@ -649,7 +651,7 @@ impl AppServer {
|
||||
fullstack_address,
|
||||
open_browser,
|
||||
self.always_on_top,
|
||||
BuildId::CLIENT,
|
||||
BuildId::PRIMARY,
|
||||
&self.client_args,
|
||||
)
|
||||
.await?;
|
||||
@@ -696,9 +698,10 @@ impl AppServer {
|
||||
false => BuildMode::Base { run: true },
|
||||
};
|
||||
|
||||
self.client.start_rebuild(build_mode.clone());
|
||||
self.client
|
||||
.start_rebuild(build_mode.clone(), BuildId::PRIMARY);
|
||||
if let Some(s) = self.server.as_mut() {
|
||||
s.start_rebuild(build_mode)
|
||||
s.start_rebuild(build_mode, BuildId::SECONDARY);
|
||||
}
|
||||
|
||||
self.clear_hot_reload_changes();
|
||||
@@ -719,8 +722,8 @@ impl AppServer {
|
||||
.unwrap_or_default();
|
||||
|
||||
let jump_table = match id {
|
||||
BuildId::CLIENT => self.client.hotpatch(bundle, cache).await,
|
||||
BuildId::SERVER => {
|
||||
BuildId::PRIMARY => self.client.hotpatch(bundle, cache).await,
|
||||
BuildId::SECONDARY => {
|
||||
self.server
|
||||
.as_mut()
|
||||
.context("Server not found")?
|
||||
@@ -730,7 +733,7 @@ impl AppServer {
|
||||
_ => bail!("Invalid build id"),
|
||||
}?;
|
||||
|
||||
if id == BuildId::CLIENT {
|
||||
if id == BuildId::PRIMARY {
|
||||
self.applied_client_hot_reload_message.jump_table = self.client.patches.last().cloned();
|
||||
}
|
||||
|
||||
@@ -759,11 +762,16 @@ impl AppServer {
|
||||
.context("Missing server jump table")?;
|
||||
|
||||
devserver
|
||||
.send_patch(server_jump_table, elapsed, BuildId::SERVER, server.pid)
|
||||
.send_patch(server_jump_table, elapsed, BuildId::SECONDARY, server.pid)
|
||||
.await;
|
||||
|
||||
devserver
|
||||
.send_patch(client_jump_table, elapsed, BuildId::CLIENT, self.client.pid)
|
||||
.send_patch(
|
||||
client_jump_table,
|
||||
elapsed,
|
||||
BuildId::PRIMARY,
|
||||
self.client.pid,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -772,8 +780,8 @@ impl AppServer {
|
||||
|
||||
pub(crate) fn get_build(&self, id: BuildId) -> Option<&AppBuilder> {
|
||||
match id {
|
||||
BuildId::CLIENT => Some(&self.client),
|
||||
BuildId::SERVER => self.server.as_ref(),
|
||||
BuildId::PRIMARY => Some(&self.client),
|
||||
BuildId::SECONDARY => self.server.as_ref(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -791,18 +799,18 @@ impl AppServer {
|
||||
pub(crate) fn applied_hot_reload_changes(&mut self, build: BuildId) -> HotReloadMsg {
|
||||
let mut msg = self.applied_client_hot_reload_message.clone();
|
||||
|
||||
if build == BuildId::CLIENT {
|
||||
if build == BuildId::PRIMARY {
|
||||
msg.jump_table = self.client.patches.last().cloned();
|
||||
msg.for_build_id = Some(BuildId::CLIENT.0 as _);
|
||||
msg.for_build_id = Some(BuildId::PRIMARY.0 as _);
|
||||
if let Some(lib) = msg.jump_table.as_mut() {
|
||||
lib.lib = PathBuf::from("/").join(lib.lib.clone());
|
||||
}
|
||||
}
|
||||
|
||||
if build == BuildId::SERVER {
|
||||
if build == BuildId::SECONDARY {
|
||||
if let Some(server) = self.server.as_mut() {
|
||||
msg.jump_table = server.patches.last().cloned();
|
||||
msg.for_build_id = Some(BuildId::SERVER.0 as _);
|
||||
msg.for_build_id = Some(BuildId::SECONDARY.0 as _);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -828,7 +836,7 @@ impl AppServer {
|
||||
pid: Option<u32>,
|
||||
) {
|
||||
match build_id {
|
||||
BuildId::CLIENT => {
|
||||
BuildId::PRIMARY => {
|
||||
// multiple tabs on web can cause this to be called incorrectly, and it doesn't
|
||||
// make any sense anyways
|
||||
if self.client.build.bundle != BundleFormat::Web {
|
||||
@@ -840,7 +848,7 @@ impl AppServer {
|
||||
}
|
||||
}
|
||||
}
|
||||
BuildId::SERVER => {
|
||||
BuildId::SECONDARY => {
|
||||
if let Some(server) = self.server.as_mut() {
|
||||
server.aslr_reference = aslr_reference;
|
||||
}
|
||||
@@ -1146,10 +1154,10 @@ impl AppServer {
|
||||
}
|
||||
|
||||
match build {
|
||||
BuildId::CLIENT => {
|
||||
BuildId::PRIMARY => {
|
||||
_ = self.client.open_debugger(dev).await;
|
||||
}
|
||||
BuildId::SERVER => {
|
||||
BuildId::SECONDARY => {
|
||||
if let Some(server) = self.server.as_mut() {
|
||||
_ = server.open_debugger(dev).await;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ impl WebServer {
|
||||
if let Some(new_socket) = new_hot_reload_socket {
|
||||
let aslr_reference = new_socket.aslr_reference;
|
||||
let pid = new_socket.pid;
|
||||
let id = new_socket.build_id.unwrap_or(BuildId::CLIENT);
|
||||
let id = new_socket.build_id.unwrap_or(BuildId::PRIMARY);
|
||||
|
||||
drop(new_message);
|
||||
self.hot_reload_sockets.push(new_socket);
|
||||
|
||||
Reference in new issue
Block a user