-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Gitsigns often fail to retrieve hunk information when staged signs is enabled #924
Comments
There is also a case where both of |
Without a good repro I can't really promise anything, I just haven't got the time. However it looks like you're on the right track to debugging this. Basically whenever we need to call an async function, anything could have happened in the buffer and this is where things go wrong. Let me know if you need help in understanding any of the code better. |
Problem: If `buf_check(...)` fails (mostly when cache is outdated), it would abort updating gitsigns, but this actually leads to the coroutine never resolving and stuck forever. It is because the asynchronous callback `cb()` is never called. As a result, gitsigns might be stuck forever and fail to update silently (see lewis6991#924), and manual reattach or refresh also doesn't work, because of the unresolved coroutine that is recognized to be "still running", i.e., any subsequent calls to "throttled" `manager.update()` will not be executed. Solution: Make `buf_check()` always yield a value (true/false) to ensure that `manager.update()` will resolve and finish its execution after all.
Thanks for your comments. While debugging, I found that manual reattaching or I think the logics around |
Problem: If `buf_check(...)` fails (mostly when cache is outdated), it would abort updating gitsigns, but this actually leads to the coroutine never resolving and stuck forever. It is because the asynchronous callback `cb()` is never called. As a result, gitsigns might be stuck forever and fail to update silently (see #924), and manual reattach or refresh also doesn't work, because of the unresolved coroutine that is recognized to be "still running", i.e., any subsequent calls to "throttled" `manager.update()` will not be executed. Solution: Make `buf_check()` always yield a value (true/false) to ensure that `manager.update()` will resolve and finish its execution after all.
This can often happen for some reason but once invalidated, gitsigns will (asynchronously) try to fix everything to work very soon, so this shouldn't be a problem. Since the fix #925, I've never seen gitsigns stop working and fail to update sign. Closing as fixed. |
Description
I know
_signs_staged_enable
is still an experimental feature, but I find this really a great and useful feature. I've run into some bugs where gitsigns stop working -- gitsigns fail to display any signs (changes on the working copy and/or the git index) sporadically.It's not very reproducible but happens quite frequently, once in a while. (Like every hour or so in my normal use) It appears to have some race condition or asynchronous operations when multiple buffers are involved.
I tried to make a minimal reproducible example but the bug was really hard to reproduce. Please excuse me not providing a fully reproducible repo, but I can share what I've found so far with some debugging efforts.
The relevant log message I see is: "compare_text was invalid, aborting" on
M.buf_check()
.Neovim version
both on nvim 0.9.4 and nightly 0.10.0-dev-1800+gc651fb304-dirty
Operating system and version
macOS
Expected behavior
Gitsigns are displayed at all times and is consistent with the actual git status, even if staged signs are enabled.
Actual behavior
Example: No gitsigns are displayed on a "broken" buffer.
Minimal config
I will skip at this point because it's really difficult to make an independent minimal repro. But will add later if I can come up with a reliable minimal repro. Below I put my current config instead.
Steps to reproduce
I will skip at this point because it's really difficult to make an independent minimal repro. But will add later if I can come up with a reliable one.
Gitsigns debug messages
Buffers:
[1], [12] are working fine, but [14] is the buffer where gitsigns is broken.
I can see the line
for the buffer where gitsigns has failed. This line was added in fef5d90 (relevant to #873)
At this point,
cache[bufnr]
has:So indeed there is no
compare_text
entry. But there iscompare_text_head
. So I suppose the logic introduced in #873 wasn't aware of "staged sign" (compare_text_head), and this is the only helpful information and context I could provide you with at the moment.Execution context:
A possible fix in
M.buf_check(...)
:The text was updated successfully, but these errors were encountered: