fix: use diagnostic instead of compilermessage giving rendered ansi logs during hotpatch (#4123)

* fix: use diagnostic instead of compilermessage giving rendered ansi logs during hotpatch

* no need for builder
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2025-05-19 17:10:11 +02:00
1 parent 0a18c12c32
commit b610ab372c
6 files changed
+24 -14

No files matched your search

+2 -2
View File
@@ -380,7 +380,7 @@ impl AppBuilder {
tracing::info!(json = ?StructuredOutput::BuildUpdate { stage: stage.clone() });
}
BuilderUpdate::CompilerMessage { message } => {
tracing::info!(json = ?StructuredOutput::CargoOutput { message: message.clone() }, %message);
tracing::info!(json = ?StructuredOutput::RustcOutput { message: message.clone() }, %message);
}
BuilderUpdate::BuildReady { bundle } => {
tracing::debug!(json = ?StructuredOutput::BuildFinished {
@@ -392,7 +392,7 @@ impl AppBuilder {
// Flush remaining compiler messages
while let Ok(Some(msg)) = self.rx.try_next() {
if let BuilderUpdate::CompilerMessage { message } = msg {
tracing::info!(json = ?StructuredOutput::CargoOutput { message: message.clone() }, %message);
tracing::info!(json = ?StructuredOutput::RustcOutput { message: message.clone() }, %message);
}
}
+3 -3
View File
@@ -2,7 +2,7 @@
use super::BuildMode;
use crate::{BuildArtifacts, BuildStage, Error, TraceSrc};
use cargo_metadata::CompilerMessage;
use cargo_metadata::diagnostic::Diagnostic;
use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};
use serde::{Deserialize, Serialize};
use std::{path::PathBuf, process::ExitStatus};
@@ -35,7 +35,7 @@ pub enum BuilderUpdate {
},
CompilerMessage {
message: CompilerMessage,
message: Diagnostic,
},
BuildReady {
@@ -92,7 +92,7 @@ impl BuildContext {
})
}
pub(crate) fn status_build_diagnostic(&self, message: CompilerMessage) {
pub(crate) fn status_build_diagnostic(&self, message: Diagnostic) {
_ = self
.tx
.unbounded_send(BuilderUpdate::CompilerMessage { message });
+7 -1
View File
@@ -320,6 +320,7 @@ use crate::{
TargetArgs, TraceSrc, WasmBindgen, WasmOptConfig, Workspace, DX_RUSTC_WRAPPER_ENV_VAR,
};
use anyhow::Context;
use cargo_metadata::diagnostic::Diagnostic;
use dioxus_cli_config::format_base_path_meta_element;
use dioxus_cli_config::{APP_TITLE_ENV, ASSET_ROOT_ENV};
use dioxus_cli_opt::{process_file_to, AssetManifest};
@@ -807,7 +808,7 @@ impl BuildRequest {
match message {
Message::BuildScriptExecuted(_) => units_compiled += 1,
Message::CompilerMessage(msg) => ctx.status_build_diagnostic(msg),
Message::CompilerMessage(msg) => ctx.status_build_diagnostic(msg.message),
Message::TextLine(line) => {
// Handle the case where we're getting lines directly from rustc.
// These are in a different format than the normal cargo output, though I imagine
@@ -829,6 +830,11 @@ impl BuildRequest {
}
}
// Handle direct rustc diagnostics
if let Ok(diag) = serde_json::from_str::<Diagnostic>(&line) {
ctx.status_build_diagnostic(diag);
}
// For whatever reason, if there's an error while building, we still receive the TextLine
// instead of an "error" message. However, the following messages *also* tend to
// be the error message, and don't start with "error:". So we'll check if we've already