Skip to content

Commit

Permalink
Add more logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Nov 11, 2024
1 parent 72e94b5 commit 080fad7
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 36 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

## Unreleased

#### 🚀 Updates

- Added more logging to debug the "File exists (os error 17)" issue.

#### 🐞 Fixes

- Fixed the wrong `proto_version` being passed to WASM function calls.
Expand Down
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ serde = { version = "1.0.214", features = ["derive"] }
serde_json = "1.0.132"
sha2 = "0.10.8"
shell-words = "1.1.0"
starbase = { version = "0.9.2" }
starbase_archive = { version = "0.8.7", features = [
starbase = { version = "0.9.4" }
starbase_archive = { version = "0.8.8", features = [
"gz",
"miette",
"tar-bz2",
Expand All @@ -41,10 +41,10 @@ starbase_archive = { version = "0.8.7", features = [
"zip-deflate",
] }
starbase_events = { version = "0.6.3" }
starbase_sandbox = { version = "0.7.4" }
starbase_shell = { version = "0.5.8", features = ["miette"] }
starbase_styles = { version = "0.4.4" }
starbase_utils = { version = "0.8.10", default-features = false, features = [
starbase_sandbox = { version = "0.7.5" }
starbase_shell = { version = "0.5.9", features = ["miette"] }
starbase_styles = { version = "0.4.5" }
starbase_utils = { version = "0.8.11", default-features = false, features = [
"json",
"miette",
"net",
Expand Down
49 changes: 40 additions & 9 deletions crates/cli/src/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::env;
use std::time::Duration;
use tokio::task::JoinSet;
use tokio::time::sleep;
use tracing::{debug, instrument};
use tracing::{debug, instrument, trace};

#[derive(Args, Clone, Debug, Default)]
pub struct InstallArgs {
Expand Down Expand Up @@ -435,12 +435,14 @@ pub async fn install_all(session: &ProtoSession) -> AppResult {

for mut tool in tools {
if let Some(version) = versions.remove(&tool.id) {
let tool_id = tool.id.clone();

let pb = mpb.add(ProgressBar::new(0));
pb.set_style(pbs.clone());

// Defer writing content till the thread starts,
// otherwise the progress bars fail to render correctly
set.spawn(async move {
let handle = set.spawn(async move {
sleep(Duration::from_millis(25)).await;

pb.set_prefix(color::id(format!(
Expand All @@ -463,23 +465,52 @@ pub async fn install_all(session: &ProtoSession) -> AppResult {
)
.await
});

trace!(
task_id = handle.id().to_string(),
"Spawning {} in background task",
color::id(tool_id)
);
}
}

let total = set.len();
let mut maybe_error: Option<miette::Report> = None;

while let Some(result) = set.join_next().await {
match result.into_diagnostic() {
Err(error) | Ok(Err(error)) => {
mpb.clear().into_diagnostic()?;
drop(mpb);
while let Some(result) = set.join_next_with_id().await {
match result {
Err(error) => {
trace!(task_id = error.id().to_string(), "Spawned task failed");

return Err(error);
maybe_error = Err(error).into_diagnostic().ok();
break;
}
Ok((task_id, Err(error))) => {
trace!(
task_id = task_id.to_string(),
"Spawned task successful but with an error"
);

maybe_error = Some(error);
break;
}
Ok((task_id, Ok(_))) => {
trace!(task_id = task_id.to_string(), "Spawned task successful");
}
_ => {}
};
}

if let Some(error) = maybe_error {
trace!("Shutting down currently running background tasks as an error has occurred");

mpb.clear().into_diagnostic()?;
drop(mpb);

set.shutdown().await;

return Err(error);
}

// When no TTY, we should display something to the user!
if mpb.is_hidden() {
println!("Successfully installed {} tools!", total);
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn get_proto_version() -> &'static Version {
env::var("PROTO_VERSION")
.ok()
.as_deref()
.unwrap_or_else(|| env!("CARGO_PKG_VERSION")),
.unwrap_or(env!("CARGO_PKG_VERSION")),
)
.unwrap()
})
Expand Down

0 comments on commit 080fad7

Please sign in to comment.