[Bug]: Slow Git checkout consumes the worktree branch-name timeout #48296
Before submitting#
- I searched existing issues and found the closed report #48267.
- I included a runnable reproduction.
Area#
apps/server
Steps to reproduce#
No provider sign-in required. On Linux, check out 4b8199987cb63f82912b8f3dbe9de6a96cdb057b and run vp install --frozen-lockfile. Save the script below as repro.sh and run bash repro.sh from the checkout root with Node 26.13.1, Git, Python 3, and curl. Pass 3 to repeat three times. A single run took 55 seconds after dependency installation. The script prints the path to its temporary server state.
This drives the real server through t3 thread start --worktree main. Git checks out a synthetic repo with a CPU-heavy content filter. The only injected code supplies the branch name after 12 seconds of simulated cold startup, within the 6–15 second range reported in #48267, plus 12 seconds of synthetic response latency. The recorded Replay provider runs the agent turn.
repro.sh
#!/usr/bin/env bash
set -euo pipefail
# Run from the repository root after vp install --frozen-lockfile.
# Optional argument: number of launches to try.
attempts="${1:-1}"
checkout="$PWD"
scratch=$(mktemp -d)
export HOME="$scratch/home" GIT_CONFIG_NOSYSTEM=1 GIT_TRACE2_EVENT="$scratch/git.jsonl"
mkdir -p "$HOME" "$scratch/state/userdata"
repo="$scratch/repo"
git init -q -b main "$repo"
git -C "$repo" config checkout.workers 1
printf '*.fixture filter=repro\n' > "$repo/.gitattributes"
for i in {1..8}; do printf 'Synthetic fixture %s\n' "$i" > "$repo/$i.fixture"; done
git -C "$repo" add .
git -C "$repo" -c user.name=Fixture -c user.email=fixture@example.invalid commit -qm fixture
# A content filter does 3.6 CPU seconds of hashing per checked-out file.
# Git still writes the original bytes and runs its ordinary checkout code.
cat > "$scratch/smudge.py" <<'PY'
import hashlib
import sys
import time
data = sys.stdin.buffer.read()
deadline = time.process_time() + 3.6
while time.process_time() < deadline:
hashlib.pbkdf2_hmac("sha256", data, b"fixture", 100_000)
sys.stdout.buffer.write(data)
PY
git -C "$repo" config filter.repro.smudge "python3 '$scratch/smudge.py'"
git -C "$repo" config filter.repro.clean cat
git -C "$repo" config filter.repro.required true
# Replace only the branch-name provider response in memory.
cat > "$scratch/generator.mjs" <<'JS'
import { registerHooks } from "node:module";
registerHooks({
load(url, context, nextLoad) {
const result = nextLoad(url, context);
if (!url.endsWith("/apps/server/src/textGeneration/TextGeneration.ts")) return result;
const source = Buffer.from(result.source).toString();
const marker = 'generateBranchName: Effect.fn("TextGeneration.generateBranchName")(function (input) {';
if (!source.includes(marker)) throw new Error("Branch generator fixture did not attach");
return {
...result,
source: source.replace(
marker,
marker + '\n return Effect.sleep("12 seconds").pipe(Effect.andThen(Effect.sleep("12 seconds")), Effect.as({ branch: "t3/repro-generator-name" }));',
),
};
},
});
JS
cat > "$scratch/state/userdata/settings.json" <<'JSON'
{
"defaultModelSelection": {"instanceId":"devReplay","model":"showcase"},
"providerInstances": {
"codex": {"driver":"codex","enabled":false},
"claudeAgent": {"driver":"claudeAgent","enabled":false},
"cursor": {"driver":"cursor","enabled":false},
"muse": {"driver":"muse","enabled":false},
"pi": {"driver":"pi","enabled":false},
"opencode": {"driver":"opencode","enabled":false},
"antigravity": {"driver":"antigravity","enabled":false}
}
}
JSON
port=$(node -e 'const s=require("node:net").createServer();s.listen(0,"127.0.0.1",()=>{console.log(s.address().port);s.close()})')
cli() { node "$checkout/apps/server/src/bin.ts" "$@" --base-dir "$scratch/state"; }
node --import "$scratch/generator.mjs" "$checkout/apps/server/src/bin.ts" serve \
--host 127.0.0.1 --port "$port" --dev-url "http://127.0.0.1:$port" \
--base-dir "$scratch/state" > "$scratch/server.log" 2>&1 &
server=$!
stop() {
if kill -0 "$server" 2>/dev/null; then kill "$server"; wait "$server" || true; fi
}
trap 'code=$?; stop; printf "Scratch directory: %s\n" "$scratch" >&2; exit "$code"' EXIT
for ((i=0; i<120; i++)); do
if curl -fs "http://127.0.0.1:$port/.well-known/t3/environment" >/dev/null; then break; fi
if ! kill -0 "$server" 2>/dev/null; then tail -40 "$scratch/server.log"; exit 2; fi
sleep 0.5
done
curl -fs "http://127.0.0.1:$port/.well-known/t3/environment" >/dev/null
cli project add "$repo" >/dev/null
failures=0
for ((attempt=1; attempt<=attempts; attempt++)); do
start=$SECONDS
launch=$(cli thread start "$repo" "Inspect the fixture" --worktree main \
--wait --json)
thread=$(node -pe 'JSON.parse(process.argv[1]).threadId' "$launch")
status=$(cli thread show "$thread" --messages 0 --json)
worktree=$(node -pe 'JSON.parse(process.argv[1]).thread.worktreePath' "$status")
branch=$(git -C "$worktree" branch --show-current)
notice=$(node --input-type=module -e '
import { DatabaseSync } from "node:sqlite";
const db = new DatabaseSync(process.argv[1], { readOnly: true });
for (const {payload_json} of db.prepare(
"SELECT payload_json FROM orchestration_v2_projection_turn_items WHERE thread_id = ? AND type = ?"
).all(process.argv[2], "system_notice")) {
const {title,message} = JSON.parse(payload_json);
if (title === "Branch not renamed") console.log(title + " — " + message);
}
' "$scratch/state/userdata/statev2.sqlite" "$thread")
printf 'Attempt %s, %ss, Git branch %s\n' "$attempt" "$((SECONDS-start))" "$branch"
if [[ -n "$notice" ]]; then printf '%s\n' "$notice"; fi
case "$branch" in
t3/repro-generator-name) [[ -z "$notice" ]] ;;
t3/[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
if [[ "$notice" != *"Timed out after 20 seconds"* ]]; then
printf 'Temporary branch without the expected timeout notice\n' >&2
exit 2
fi
failures=$((failures+1)) ;;
*) printf 'Unexpected branch %s\n' "$branch" >&2; exit 2 ;;
esac
[[ "$worktree" = "$scratch/state/worktrees/"* ]]
git -C "$repo" worktree remove --force "$worktree"
git -C "$repo" branch -D "$branch" >/dev/null
done
printf '%s/%s launches kept the temporary branch\n' "$failures" "$attempts"
[[ "$failures" = 0 ]]
Expected behavior#
The thread runs on t3/repro-generator-name because the name is available before Git finishes and the agent can start.
Actual behavior#
All 3 of 3 launches on upstream main kept a temporary t3/<hex> branch. Git Trace2 recorded successful git worktree add runs of 29.6–30.5 seconds. The server records Branch not renamed with Timed out after 20 seconds, even though Git succeeds. With fork commit 54bb7b10ed90067bb47cb6802e55c5c1539d9eb0, the same script passed in 1 of 1 launches. Git and the thread showed t3/repro-generator-name, and the notice was absent.
This is a follow-up to #48267. The maintainer's Deferred harness result showed the same temporary branch and notice.
Impact#
Minor bug or occasional failure
Version or commit#
Upstream main at 4b8199987cb63f82912b8f3dbe9de6a96cdb057b.
Environment#
Ubuntu 22.04 x86_64, Node 26.13.1, Git 2.56.1, Docker capped at 6 CPUs and 6 GiB RAM. Git uses one checkout worker.
tanstack-source added labelsbug
Sign in to join this conversation.