mirror of
https://github.com/openai/codex.git
synced 2026-05-01 01:47:18 +00:00
fix: session downgrade (#8196)
The problem is that the `tokio` task own an `Arc` reference of the session and that this task only exit with the broadcast channel get closed. But this never get closed if the session is not dropped. So it's a snake biting his tail basically The most notable result was that non of the `Drop` implementation were triggered (temporary files, shell snapshots, session cleaning etc etc) when closing the session (through a `/new` for example) The fix is just to weaken the `Arc` and upgrade it on the fly
This commit is contained in:
@@ -738,11 +738,14 @@ impl Session {
|
||||
.services
|
||||
.skills_manager
|
||||
.subscribe_skills_update_notifications();
|
||||
let sess = Arc::clone(&sess);
|
||||
let sess = Arc::downgrade(&sess);
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
match rx.recv().await {
|
||||
Ok(()) => {
|
||||
let Some(sess) = sess.upgrade() else {
|
||||
break;
|
||||
};
|
||||
let turn_context = sess.new_default_turn().await;
|
||||
sess.send_event(turn_context.as_ref(), EventMsg::SkillsUpdateAvailable)
|
||||
.await;
|
||||
|
||||
Reference in New Issue
Block a user