fix: Replace Runtime::new().block_on() with thread::spawn in AuthConfig
Some checks failed
BotServer CI/CD / build (push) Failing after 1m14s
Some checks failed
BotServer CI/CD / build (push) Failing after 1m14s
- AuthConfig::from_env() was creating a new Runtime and calling block_on
directly, causing panic when main tokio runtime is already active
- Now uses std:🧵:spawn + new_current_thread().block_on() pattern
- Follows AGENTS.md pattern for async-from-sync bridges
This commit is contained in:
parent
c0c06e92eb
commit
0d3cfbe0f7
1 changed files with 27 additions and 20 deletions
|
|
@ -54,13 +54,21 @@ impl AuthConfig {
|
|||
|
||||
if let Ok(secret) = std::env::var("VAULT_TOKEN") {
|
||||
if !secret.is_empty() {
|
||||
let rt = tokio::runtime::Runtime::new().ok();
|
||||
if let Some(rt) = rt {
|
||||
let sm = crate::core::shared::utils::get_secrets_manager_sync();
|
||||
if let Some(sm) = sm {
|
||||
if let Ok(secrets) =
|
||||
rt.block_on(sm.get_secret(crate::core::secrets::SecretPaths::JWT))
|
||||
{
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
std::thread::spawn(move || {
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build();
|
||||
let result = if let Ok(rt) = rt {
|
||||
rt.block_on(async { sm.get_secret(crate::core::secrets::SecretPaths::JWT).await })
|
||||
} else {
|
||||
Err("Failed to create runtime".into())
|
||||
};
|
||||
let _ = tx.send(result);
|
||||
});
|
||||
if let Ok(Ok(secrets)) = rx.recv() {
|
||||
if let Some(s) = secrets.get("secret") {
|
||||
config.jwt_secret = Some(s.clone());
|
||||
}
|
||||
|
|
@ -78,7 +86,6 @@ impl AuthConfig {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue