-
-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Hello!
Describe the bug
Blocked shell sometimes does not unblock. I cannot provide steps to reproduce because it happens sporadically.
The quickest way I'm able to reproduce is committing with lazygit inside toggleterm and setting up an auto command to delete the buffer after writing. It happens 1-5 times out of 10.
Expected behavior
Shell to unblock
Desktop (please complete the following information):
- Debian 12 on WSL
- Wezterm + Tmux
- Neovim 0.10.0
Additional context
After many trials and errors: scheduling API functions in callbacks, deferring them with long timeouts, with short timeouts, I may have an idea of what's happening:
diff --git a/lua/flatten/core.lua b/lua/flatten/core.lua
index 0d1622f..81adaa9 100644
--- a/lua/flatten/core.lua
+++ b/lua/flatten/core.lua
@@ -9,7 +9,9 @@ function M.unblock_guest(guest_pipe)
"vim.cmd.qa({ bang = true })",
{}
)
- vim.fn.chanclose(response_sock)
+ vim.defer_fn(function()
+ vim.fn.chanclose(response_sock)
+ end, 1000)
end
function M.notify_when_done(pipe, bufnr, callback, ft)My idea is that the channel gets closed before guest fully receives the command to close. That's why I tried to give the guest a good second to get the command. With this patch it looks that the freezing is not happening. I'm going to test drive this patch for a few days to see if that's indeed the case.
Also, I'm also deferring closing the channel in maybe_block() just for good measure and I've increased sleep time since (I think) there's not point in wasting CPU time waking up and going to sleep every second.
diff --git a/lua/flatten/guest.lua b/lua/flatten/guest.lua
index ef43b56..107b2b5 100644
--- a/lua/flatten/guest.lua
+++ b/lua/flatten/guest.lua
@@ -20,9 +20,11 @@ function M.maybe_block(block)
if not block then
vim.cmd.qa({ bang = true })
end
- vim.fn.chanclose(host)
+ vim.defer_fn(function()
+ vim.fn.chanclose(host)
+ end, 1000)
while true do
- vim.cmd.sleep(1)
+ vim.cmd.sleep(10)
end
endPlease, provide any thoughts and ideas on this issue.