diff --git a/crates/doc/src/wasmer_cli/commands/login.rs.html b/crates/doc/src/wasmer_cli/commands/login.rs.html index 07061b44ddb..8be5097708c 100644 --- a/crates/doc/src/wasmer_cli/commands/login.rs.html +++ b/crates/doc/src/wasmer_cli/commands/login.rs.html @@ -517,6 +517,32 @@ 516 517 518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544
use std::{net::TcpListener, path::PathBuf, str::FromStr, time::Duration};
use anyhow::Ok;
@@ -809,11 +835,21 @@
match auth_state {
AuthorizationState::TokenSuccess(token) => {
- match wasmer_registry::login::login_and_save_token(
- env.dir(),
- registry.as_str(),
- &token,
- )? {
+ let res = std::thread::spawn({
+ let dir = env.dir().to_owned();
+ let registry = registry.clone();
+ move || {
+ wasmer_registry::login::login_and_save_token(
+ &dir,
+ registry.as_str(),
+ &token,
+ )
+ }
+ })
+ .join()
+ .map_err(|err| anyhow::format_err!("handler thread died: {err:?}"))??;
+
+ match res {
Some(s) => {
print!("Done!");
println!("\n✅ Login for Wasmer user {:?} saved", s)
@@ -1034,6 +1070,22 @@
.to_string();
assert_eq!(wasmer_env_token_help, login_token_help);
}
+
+ /// Regression test for panics on API errors.
+ /// See https://github.com/wasmerio/wasmer/issues/4147.
+ #[test]
+ fn login_with_invalid_token_does_not_panic() {
+ let cmd = Login {
+ no_browser: true,
+ wasmer_dir: WASMER_DIR.clone(),
+ registry: Some("http://localhost:11".to_string().into()),
+ token: Some("invalid".to_string()),
+ cache_dir: None,
+ };
+
+ let res = cmd.execute();
+ assert!(res.is_err());
+ }
}