The `Discard Changes` button hangs
Version
0.14.13
Operating System
Windows
Distribution Method
msi (Windows)
Describe the issue
The Discard Changes button hangs periodically without any visible warning or message. A message with a question remains on the screen until canceled and sometimes hangs after restarting GitButler.
I didn't see any reason or pattern: sometimes it hangs if I try to undo changes in locked files. Sometimes it hangs in large branches.
How to reproduce (Optional)
- Cancel a commit or make changes to any file
- Open context menu
- Click Discard Changes
- See the issue and no response at all
Expected behavior (Optional)
- Cancel a commit or make changes to any file
- Open context menu
- Click Discard Changes
- See an error message or other warning.
- Force ignore changes regardless of the warning
Relevant log output (Optional)
Thanks a lot for reporting!
It would be interesting to know if there is high CPU when it hangs. If not, it's very likely that the backend panicked which will leave the UI waiting forever without a sign that this happened, except for in the logs.
Discarding files was also completely rewritten, and it's will be available with the next major release.
Upd: I can't Discard changes, Discard line and Discard hunk in locked file. There's no any errors and messages
Thanks a lot for reporting!
It would be interesting to know if there is high CPU when it hangs. If not, it's very likely that the backend panicked which will leave the UI waiting forever without a sign that this happened, except for in the logs.
Discarding files was also completely rewritten, and it's will be available with the next major release.
no high cpu, no messages in logs (see new comment)
Thanks for taking a look.
And right, without high CPU I think panics are only (and really) be visible in the tokio logs though (next to the application logs).
I've tried to discard changes in empty branch:
Tokio:
{"Exit":{"id":6756498952683545,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":484481400}}}
{"Enter":{"id":6756498952683545,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":484491400}}}
{"Exit":{"id":6756498952683545,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":484493700}}}
{"Close":{"id":6756498952683545,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":484494900}}}
{"Exit":{"id":58547894667444251,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":485494500}}}
{"Enter":{"id":58547894667444251,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":485504200}}}
{"Exit":{"id":58547894667444251,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":485506300}}}
{"Close":{"id":58547894667444251,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":485507700}}}
{"Exit":{"id":29274497089536026,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":695259100}}}
{"Enter":{"id":29274497089536026,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":695269400}}}
{"Exit":{"id":29274497089536026,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":695271500}}}
{"Close":{"id":29274497089536026,"at":{"secs_since_epoch":1743756833,"nanos_since_epoch":695272600}}}
last log:
2025-04-04T08:53:53.436049Z INFO set_project_active:set_project_to_window:file monitor:handle debounced events: crates\gitbutler-watcher\src\file_monitor.rs:119: new id=414c02e1-fbdc-4021-b686-35b93458c777 window="main" project_id=414c02e1-fbdc-4021-b686-35b93458c777
2025-04-04T08:53:53.459374Z INFO set_project_active:set_project_to_window:file monitor:handle debounced events: crates\gitbutler-watcher\src\file_monitor.rs:119: close time.busy=23.3ms time.idle=39.3µs id=414c02e1-fbdc-4021-b686-35b93458c777 window="main" project_id=414c02e1-fbdc-4021-b686-35b93458c777 fs_events=722 fs_events=722 ignored=0 ignored=0 git_noop=700 git_noop=700 git=2 git=2 project=1 project=1 git_dedup=2 git_dedup=2 project_dedup=1 project_dedup=1
2025-04-04T08:53:53.459527Z INFO handle: crates\gitbutler-watcher\src\handler.rs:55: new event=GitFileChange(414c02e1-fbdc-4021-b686-35b93458c777, index, logs\HEAD)
2025-04-04T08:53:53.459610Z INFO handle: crates\gitbutler-watcher\src\handler.rs:55: new event=ProjectFileChange(414c02e1-fbdc-4021-b686-35b93458c777, QuickSwitch-1.4.ahk)
2025-04-04T08:53:53.459790Z INFO handle: crates\gitbutler-watcher\src\handler.rs:55: new event=GitButlerOplogChange(414c02e1-fbdc-4021-b686-35b93458c777)
2025-04-04T08:53:53.463903Z INFO handle: crates\gitbutler-watcher\src\handler.rs:55: close time.busy=4.36ms time.idle=11.0µs event=GitFileChange(414c02e1-fbdc-4021-b686-35b93458c777, index, logs\HEAD)
2025-04-04T08:53:53.464586Z INFO handle:project_files_change: crates\gitbutler-watcher\src\handler.rs:146: new event=ProjectFileChange(414c02e1-fbdc-4021-b686-35b93458c777, QuickSwitch-1.4.ahk) paths=1
2025-04-04T08:53:53.464920Z INFO handle: crates\gitbutler-watcher\src\handler.rs:55: close time.busy=5.12ms time.idle=12.4µs event=GitButlerOplogChange(414c02e1-fbdc-4021-b686-35b93458c777)
2025-04-04T08:53:53.650211Z INFO handle:project_files_change:calculate_virtual_branches: crates\gitbutler-watcher\src\handler.rs:105: new event=ProjectFileChange(414c02e1-fbdc-4021-b686-35b93458c777, QuickSwitch-1.4.ahk) paths=1
2025-04-04T08:53:53.674288Z INFO handle:project_files_change:calculate_virtual_branches: crates\gitbutler-watcher\src\handler.rs:105: close time.busy=24.0ms time.idle=35.4µs event=ProjectFileChange(414c02e1-fbdc-4021-b686-35b93458c777, QuickSwitch-1.4.ahk) paths=1
2025-04-04T08:53:53.674355Z INFO handle:project_files_change: crates\gitbutler-watcher\src\handler.rs:146: close time.busy=210ms time.idle=22.4µs event=ProjectFileChange(414c02e1-fbdc-4021-b686-35b93458c777, QuickSwitch-1.4.ahk) paths=1
2025-04-04T08:53:53.674712Z INFO handle: crates\gitbutler-watcher\src\handler.rs:55: close time.busy=215ms time.idle=26.7µs event=ProjectFileChange(414c02e1-fbdc-4021-b686-35b93458c777, QuickSwitch-1.4.ahk)
2025-04-04T08:53:54.438604Z INFO set_project_active:set_project_to_window:file monitor:handle debounced events: crates\gitbutler-watcher\src\file_monitor.rs:119: new id=414c02e1-fbdc-4021-b686-35b93458c777 window="main" project_id=414c02e1-fbdc-4021-b686-35b93458c777
2025-04-04T08:53:54.438758Z INFO set_project_active:set_project_to_window:file monitor:handle debounced events: crates\gitbutler-watcher\src\file_monitor.rs:119: close time.busy=112µs time.idle=44.4µs id=414c02e1-fbdc-4021-b686-35b93458c777 window="main" project_id=414c02e1-fbdc-4021-b686-35b93458c777 fs_events=15 fs_events=15 ignored=0 ignored=0 git_noop=15 git_noop=15 git=0 git=0 project=0 project=0
That's really interesting - I don't even see the discard call in the logs. This might be accidental, but from what's presented here the UI does nothing when the button is pressed.
If that were the case, there might be an error in the javascript console? It should be available via View -> Developer Tools.
Well, you're right! I can generate an error on click. But Discard hunk does nothing. No errors, logs and actions.
Maybe that's the lead we were looking for! My feeling is that the code first tries to close the window before performing the actual action maybe, and as the closing fails nothing material happens? Maybe @estib-vega knows more.