Skip to content

[Bug]: Failed worktree submodule update leaves half-initialized dirty submodule directories and proceeds as ready #37027

Closed

Description

@zonuexe

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Open a repository with .gitmodules (e.g. rigortype/rigor, 13 submodules under references/, including large repositories such as ruby/ruby, phpstan/phpstan, microsoft/TypeScript-Website, sorbet/sorbet) with default worktreeSubmodules ("recursive").
  2. Launch a new worktree thread or delegated task (delegate_task with isolation: "worktree").
  3. GitVcsDriver.createWorktree runs git worktree add, then git submodule init, then git submodule update --init --recursive with timeoutMs: null.
  4. Wait until git submodule update --init --recursive fails (exitCode: 1 after downloading/failing on submodules — in our traces, ~2 hours 9 minutes).

Expected behavior

  1. When git submodule update fails during worktree creation, T3 Code should not silently leave half-initialized submodule directories (.git gitdir pointer only, empty working tree) that make git status and git diff report modified/dirty submodules across the worktree.
  2. Either fail/roll back or report the failed submodule state cleanly rather than swallowing GitCommandError as a warning and handing a broken dirty worktree to the agent (which then blocks git tooling unless -c diff.ignoreSubmodules=all is passed).
  3. Combined with [Bug]: New worktree creation reclones already-initialized submodule objects #9853 (recloning already-populated .git/modules from remote) and [Bug]: Automatic worktree submodule checkout can wait indefinitely and blocks /side #33017 (timeoutMs: null / interactive auth env), large submodule sets should not block preparing for hours.

Actual behavior

In T3 Code Beta 0.1.9 (24e77473ecf4), GitVcsDriver.createWorktree completes git worktree add in under a second (~740–790 ms), then blocks on GitVcsDriver.createWorktree.updateSubmodules (git submodule update --init --recursive, timeoutMs: null) for over 2 hours.

When updateSubmodules exits with exitCode: 1, createWorktree logs:

worktree submodule checkout failed; submodules may be incomplete

and returns Success. On disk, 12 submodules are left containing only a .git file (gitdir: .../worktrees/<id>/modules/...) with empty working trees, while git status --short marks all 12 as dirty ( M references/... / m references/...). Any subsequent script or agent step that checks for a clean diff or runs git diff fails unless submodules are explicitly ignored.

Impact

Major degradation or frequent failure

Version or commit

0.1.9 (commit 24e7747)

Environment

macOS (arm64), T3 Code Beta 0.1.9 (24e77473ecf4), Git 2.56.1

Logs or stack traces

From server.trace.ndjson:

{
  "name": "GitVcsDriver.createWorktree.updateSubmodules",
  "durationMs": 7768571.266084,
  "attributes": {
    "git.operation": "GitVcsDriver.createWorktree.updateSubmodules",
    "git.args_count": 4
  },
  "exit": { "_tag": "Success" }
}
{
  "name": "createWorktree",
  "durationMs": 7769359.464166,
  "events": [
    {
      "name": "[\"worktree submodule checkout failed; submodules may be incomplete\", {\"cause\": {\"_tag\": \"GitCommandError\", \"operation\": \"GitVcsDriver.createWorktree.updateSubmodules\", \"command\": \"git\", \"argumentCount\": 4, \"exitCode\": 1, \"stdoutLength\": 0, \"stderrLength\": 2258, \"detail\": \"Git command exited with a non-zero status.\"}}]"
    }
  ],
  "exit": { "_tag": "Success" }
}

Resulting git status --short in the created worktree:

 M references/TypeScript-Website
 M references/elixir-lang.github.com
 M references/ex_doc
 M references/hanakai-rb
 M references/python-typing
 M references/rbs
 m references/rbs-inline-wiki
 M references/ruby
 M references/sorbet
 M references/steep
 M references/tapioca
 M references/typeprof

(Same failure also occurred on a second worktree on the same repo: updateSubmodules 7,716,565 ms -> exitCode: 1; a third worktree remained stuck in preparing for 5,823,310 ms before manual cancellation.)

Related issues

Workaround

Set worktreeSubmodules to "none" in T3 Code project settings (or projectSettingsOverrides.<projectId>.worktreeSubmodules = "none" in settings.json, or in t3.json), which skips submodule init / submodule update during worktree creation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions