Repository navigation
sidebar: Fix hang caused by archiving a thread from a worktree that was deleted from disk - #65202
Conversation
…as deleted from disk
smitbarmase
left a comment
There was a problem hiding this comment.
Thanks for tracking this down! Your regression test made this easy to verify, so I'm keeping it.
I'm going to close this because the new check runs fs.metadata on the local disk, even when the thread's worktree lives on an SSH remote. Those paths usually don't exist locally, so archiving a remote worktree thread would skip opening its workspace and never clean up the worktree.
find_or_create_workspace already checks whether the paths exist, on the right machine. The loop comes from archive_thread ignoring the workspace that open returns and starting over, so I'm fixing it there instead.
Getting to that fix took a fair bit of digging through the archive flow, and it turned up a related bug where the workspace opened for archiving stays in the sidebar as an extra project group. Both fixes touch the same code, so it's quicker for me to put them up together than to send this back with a long list of changes.
|
Thanks for the response and fix. I'll make sure to consider and test SSH remote sessions for future PRs. Can you link the fix/PR you mentioned so I can take a look and learn from it? |
|
@mpyuglgwkxcmodyrpo here you go: #65578 |
Summary
Closes #57957 and duplicate #64977.
Infinite task loop caused by attempting to open a worktree that was deleted from disk.
Root cause
The
archive_threadtask will schedule itself forever becauseshould_load_closed_workspace_for_archivereturns true for deleted linked worktrees because it only checks whetherfolder_paths != project_group_key.path_list(), butfind_or_create_local_workspacesilently falls back to the main project when those paths are missing on disk, so the opened workspace never matches the thread’sfolder_pathsandrebuild_contentskeeps producingThreadEntryWorkspace::Closedindefinitely causing another scheduling ofarchive_thread.Notably this is not a problem on the "Thread History" sidebar panel because it does not try to open the workspace before archiving. This only affects the regular active (unarchived) threads sidebar.
Reproduction
I am finding that this problem mainly exists for External Agents, so if you are testing this here are the steps to reproduce:
Fix
Check if the worktree exists before trying to open it, breaking the
archive_threadtask loop.Testing
test_archive_thread_from_deleted_linked_worktree_does_not_loop)Self-review
Release Notes: