Skip to content

Commit

Permalink
Merge pull request #93 from thomastaylor312/fix/provider_log_init
Browse files Browse the repository at this point in the history
fix(rpc): Prevents early provider exit when logger is set
  • Loading branch information
thomastaylor312 authored Mar 7, 2022
2 parents c9004af + e326d47 commit c789836
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rpc-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wasmbus-rpc"
version = "0.8.2"
version = "0.8.3"
authors = [ "wasmcloud Team" ]
license = "Apache-2.0"
description = "Runtime library for actors and capability providers"
Expand Down
12 changes: 9 additions & 3 deletions rpc-rs/src/provider_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ where
use std::str::FromStr as _;

// initialize logger
let log_rx = crate::channel_log::init_logger()
.map_err(|_| RpcError::ProviderInit("log already initialized".to_string()))?;
crate::channel_log::init_receiver(log_rx);
match crate::channel_log::init_logger() {
Ok(log_rx) => crate::channel_log::init_receiver(log_rx),
// TODO(thomastaylor312): This is brittle, but the init_logger function is public and this
// is a bug fix. For the next major release, we should create an enum return type
Err(e) if e.contains("logger init error") => {
eprintln!("Logger was already created by provider, skipping receiver initialization");
}
Err(e) => return Err(e.into()),
}

let (shutdown_tx, shutdown_rx) = tokio::sync::oneshot::channel();
eprintln!(
Expand Down

0 comments on commit c789836

Please sign in to comment.