Skip to content

Git subprocesses not properly terminated, causing process accumulation #1418

@nsingl00

Description

@nsingl00

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:

  1. 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"))
  1. pexpect timeout set to None
p = pexpect.spawn(
   cmdline[0], cmdline[1:], cwd=cwd, env=env,
   encoding="utf-8", timeout=None  # 
)
  1. 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

  1. Start JupyterLab with git extension enabled
  2. Open a git repository with remote branches
  3. Perform operations that might hang (network issues, authentication problems)
  4. Run ps aux | grep git to see accumulating git processes
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions