-
Notifications
You must be signed in to change notification settings - Fork 362
Open
Labels
Description
Description
JupyterLab Git extension creates git subprocesses that are not properly terminated under certain conditions, leading to accumulation of hanging git processes that consume system resources.
Root Cause Analysis
The issue stems from several subprocess management problems in jupyterlab_git/git.py:
- Missing timeout in process.communicate()
def call_subprocess(cmdline, cwd=None, env=None, is_binary=is_binary):
process = subprocess.Popen(
cmdline, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd, env=env
)
output, error = process.communicate() # ----- NO TIMEOUT - can hang indefinitely
return (process.returncode, output.decode("utf-8"), error.decode("utf-8"))
- pexpect timeout set to None
p = pexpect.spawn(
cmdline[0], cmdline[1:], cwd=cwd, env=env,
encoding="utf-8", timeout=None #
)
- No process termination on errors/timeouts- No explicit process.terminate() or process.kill() calls in error paths
- Missing process cleanup context managers
- Reliance on Python garbage collection for cleanup
Reproduction Steps
- Start JupyterLab with git extension enabled
- Open a git repository with remote branches
- Perform operations that might hang (network issues, authentication problems)
- Run ps aux | grep git to see accumulating git processes
- Notice processes remain even after operations complete or fail
Expected Behavior
- Git subprocesses should be properly terminated after completion
- Hanging processes should be killed after timeout
- No git subprocess accumulation over time
Actual Behavior
- Git subprocesses can hang indefinitely
- Processes accumulate and consume system resources
- No automatic cleanup of stuck processes