-
Notifications
You must be signed in to change notification settings - Fork 37
already mutably borrowed: BorrowError #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @yoannfleurydev, |
Hi, no, not at this time sorry. |
So I fixed the issue by reducing the scope of the borrows but for some reason it is still failing to renew the authorization, there doesn't seem to be any other errors in the process. This is all done through the standard ServiceSession that comes with the crate and works perfectly fine for the first hour. pub mod service_account {
...
impl super::FirebaseAuthBearer for Session {
...
fn access_token(&self) -> String {
if jwt_update_expiry_if(&mut self.jwt.borrow_mut(), self.refresh_minutes) {
if let Some(secret) = self.credentials.keys.secret.as_ref() {
match self.jwt.borrow().encode(&secret.deref()) {
Ok(v) => {
match v.encoded() {
Ok(v2) => {
self.access_token_.swap(&RefCell::new(v2.encode()));
}
Err(e) => {
panic!("{:?}", e)
}
}
}
Err(e) => {
panic!("{}", e);
}
}
}
}
self.access_token_.borrow().clone()
}
}
} After the hour has passed requests start returning This is how my initialization looks: impl Firestore {
pub fn new() -> Firestore {
let cred = Credentials::from_file("firebase-service-account.json")
.expect("Failed to load service file!");
let session = ServiceSession::new(cred, 59)
.expect("Failed to create session!");
Firestore {
session
}
}
} |
+1 |
Should be fixed. This is an RwLock now. |
Describe the bug
My program did stop with the following error:
Looking at the
sessions.rs
line (308 in the log, 488 in this repo source code) it seems that the call to.borrow()
is panicking.I'm kind of new to Rust so I'm not sure everything is right on my side.
To Reproduce
Here is my program https://github.com/BearStudio/twitch-listener
Steps to reproduce the behavior:
cargo run
Expected behavior
I expect my program not to panic.
The text was updated successfully, but these errors were encountered: