zielu / GitToolBox

GitToolBox IntelliJ plugin
GNU General Public License v3.0
604 stars 73 forks source link

[BUG] Git Fetch Cancel not working as expected #385

Closed 0xC0DEBA5E closed 2 years ago

0xC0DEBA5E commented 2 years ago

I'm working with a Git repo that is accessible only via VPN.

When I forget to connect to my VPN before issuing a command that triggers a git fetch in my IDE, then I have to wait until the Git fetch background tasks runs into the timeout. It seems to me like the cancel button on the Git fetch operation just hides the message and in the background the network request to the unreachable IP-Address is not stopped. For the next Git fetch operation after connecting to the VPN I always have to wait until this hidden background task is being killed by the timeout. Otherwise the new operation will also hang.

This only happens when the Git ToolBox plugin is enabled.

To Reproduce Steps to reproduce the behavior:

  1. Open a Project with a repo that uses an IP that is only accessible via VPN and don't connect the VPN. If you use a hostname or an IP from a public range that cannot be reached this will not happen.
  2. Click on the "Update Project" Git Button or start a git fetch in the git menu of the IDE.
  3. The fetch should take a long time until it reaches a timeout. If you try to cancel it, it will just hide the "Fetching..." message but not really stop the background process.
  4. Connect to the VPN and try again. It will work only after the background git fetch operation runs into the timeout.

With some further testing I found out that this seems to happen only in a very few cases. I believe you have to use an IP instead of a hostname for the git repo url, otherwise the failing name resolution will stop the fetch process at an earlier stage. But maybe the fix to this problem solves a problem for someone else too, so I wanted to share my observations.

Expected behavior It should be possible to really stop the background git fetch process. If the plugin is disabled, this seems to work.

Plugin version 212.8.5

IDE version PhpStorm 2021.3.2 Build #PS-213.6777.58, built on January 31, 2022 Runtime version: 11.0.13+7-b1751.25 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Linux 5.15.16-200.fc35.x86_64 GC: G1 Young Generation, G1 Old Generation Memory: 8384M Cores: 8 Registry: debugger.watches.in.variables=false run.processes.with.pty=TRUE ide.balloon.shadow.size=0 js.debugger.webconsole=false

Non-Bundled Plugins: org.jetbrains.plugins.go-template (213.6777.8) net.sjrx.intellij.plugins.systemdunitfiles (0.3.4) net.seesharpsoft.intellij.plugins.csv (2.18.2) com.thvardhan.gradianto (4.4) com.intellij.ideolog (203.0.27.0) com.intellij.properties (213.6461.46) com.github.b3er.idea.plugins.arc.browser (0.23) com.firsttimeinforever.intellij.pdf.viewer.intellij-pdf-viewer (0.13.0) YAML/Ansible support (0.11.2) zielu.gittoolbox (212.8.5) mobi.hsz.idea.gitignore (4.3.0) com.jetbrains.plugins.jade (213.5744.223) intellij.prettierJS (213.6461.6) com.dmarcotte.handlebars (213.5744.190) com.intellij.kubernetes (213.6777.8) ru.adelf.idea.dotenv (2022.1)

Current Desktop: GNOME

Screenshots I used the following button to cancel the fetch: image

This will appear after approx. 2mins, when the background process runs into the timeout. image

zielu commented 2 years ago

Hi, I'll take a look what is wrong here

zielu commented 2 years ago

My plugin uses JB Git Integration APIs to invoke the fetch, they use CLI git to do it. Looking at that code it is possible to cancel the operation in several point in time but the moment git fetch command is invoked it has to run till completion - there is no way to cancel it.

0xC0DEBA5E commented 2 years ago

Ok, thank you for having a look at this. As this is just a little annoyance for me in some situations I think this issue can be closed now. Thanks.