From 1b51382d1050a188ad3de1595bd0cf3054ad7fda Mon Sep 17 00:00:00 2001 From: Jonathan Ringer Date: Thu, 20 Jul 2023 09:24:00 -0700 Subject: [PATCH] [Keyserver/rust] Improve debugging Summary: This was useful in helping track down https://linear.app/comm/issue/ENG-4418. Would like to see these changes persisted so if errors do arise in the future, we get more than nothing Test Plan: ``` cd keyserver RUST_LOG=debug yarn dev ``` Reviewers: bartek, varun Reviewed By: bartek Subscribers: ashoat, tomek Differential Revision: https://phab.comm.dev/D8587 --- .../addons/rust-node-addon/src/identity_client/login.rs | 8 ++++++-- keyserver/src/user/login.js | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/keyserver/addons/rust-node-addon/src/identity_client/login.rs b/keyserver/addons/rust-node-addon/src/identity_client/login.rs index 0a7158b308..ce1451efe2 100644 --- a/keyserver/addons/rust-node-addon/src/identity_client/login.rs +++ b/keyserver/addons/rust-node-addon/src/identity_client/login.rs @@ -27,7 +27,7 @@ pub async fn login_user( let mut client_login = Login::new(); let opaque_login_request = client_login .start(&password) - .map_err(|_| Error::from_status(Status::GenericFailure))?; + .map_err(|_| Error::from_reason("Failed to create opaque login request"))?; let login_start_request = OpaqueLoginStartRequest { opaque_login_request, @@ -51,26 +51,30 @@ pub async fn login_user( }), }; + debug!("Starting login to identity service"); let login_start_response = identity_client .login_password_user_start(login_start_request) .await .map_err(handle_grpc_error)? .into_inner(); + debug!("Received login response from identity service"); let opaque_login_upload = client_login .finish(&login_start_response.opaque_login_response) - .map_err(|_| Error::from_status(Status::GenericFailure))?; + .map_err(|_| Error::from_reason("Failed to finish opaque login request"))?; let login_finish_request = OpaqueLoginFinishRequest { session_id: login_start_response.session_id, opaque_login_upload, }; + debug!("Attempting to finalize opaque login exchange with identity service"); let login_finish_response = identity_client .login_password_user_finish(login_finish_request) .await .map_err(handle_grpc_error)? .into_inner(); + debug!("Finished login with identity service"); let user_info = UserLoginInfo { user_id: login_finish_response.user_id, access_token: login_finish_response.access_token, diff --git a/keyserver/src/user/login.js b/keyserver/src/user/login.js index 74640efb77..2c451913d0 100644 --- a/keyserver/src/user/login.js +++ b/keyserver/src/user/login.js @@ -172,6 +172,7 @@ async function registerOrLogin(): Promise { ]); return identity_info; } catch (e) { + console.warn('Failed to login user: ' + getMessageForException(e)); try { const identity_info = await rustAPI.registerUser( userInfo.username,