Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Releasing the last Git HEAD watcher can freeze the macOS server for over a minute #47958

Openkarajan1001(GitHub profile, opens in a new tab) opened this issue 0 comments

What happened

T3 Code 0.1.13 on macOS showed “is reconnecting” while the desktop was connected directly to the service on loopback. During one occurrence, the server took 36.3 seconds to release a Git watcher. The banner appeared during that interval. The same operation on a fresh T3 service with an empty Git repository stalled unrelated HTTP requests. No model or relay connection is needed to reproduce the server-side stall.

Area and environment

  • apps/server, T3 Code v0.1.13, macOS 26.6.2 (25G83), Apple Silicon.
  • The standalone T3 server embeds Node 26.13.1. The separate desktop-runtime diagnostic below used Electron 44.10.1 with Node 24.22.1.
  • Impact: repeated loss of responsiveness across connections to the affected service. The stall duration varies on this machine.

Steps to reproduce

  1. On macOS, start an isolated t3 serve with a fresh --base-dir, a loopback address and an unused port. Create an empty Git repository in a temporary directory.
  2. Through a local authenticated T3 connection, subscribe to subscribeVcsBranch for that repository and wait for its initial branch snapshot. Keep this as the only subscriber for that repository.
  3. Cancel the subscription. From a separate client, measure HTTP responsiveness during cancellation. Inspect the VcsStatusBroadcaster.releaseHeadWatcher span in userdata/logs/server.trace.ndjson.
  4. Subscribe again and repeat. With the stock service, two successive release spans measured 54,567 ms and 103,016 ms. A concurrent loopback HTTP probe timed out at 50 seconds.

This smaller diagnostic isolates watcher disposal from Git, T3 connections, and model providers. Save it as watch-close.cjs and run it on macOS:

const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");

const dir = fs.mkdtempSync(path.join(os.tmpdir(), "t3-watch-"));
const watcher = fs.watch(dir, { recursive: false }, () => {});
setTimeout(() => {
  const start = performance.now();
  setImmediate(() => {
    console.log("next event-loop turn (ms):", (performance.now() - start).toFixed(1));
    fs.rmdirSync(dir);
  });
  watcher.close();
  console.log("close() returned (ms):", (performance.now() - start).toFixed(1));
}, 250);

To use the same runtime as the desktop diagnostic:

ELECTRON_RUN_AS_NODE=1 "/Applications/T3 Code (Beta).app/Contents/MacOS/T3 Code (Beta)" ./watch-close.cjs

On the affected Mac, the desktop diagnostic measured 6,042.5 ms before close() returned and 6,044.9 ms until the next event-loop turn. A separate run with standalone Node 23.10.0 took 1.2 ms to return. A fast run is possible. A native sample from a separate desktop-runtime reproduction showed the main thread waiting in uv__fsevents_close and the FSEvents thread in FSEventStreamStop → f2d_unregister_rpc. The reason macOS took so long to unregister the stream on this host is still unknown.

Expected behavior and regression coverage

The last subscriber can leave while unrelated HTTP requests and WebSocket heartbeats continue to receive responses. A new subscriber still sees the current branch, including after Git atomically replaces HEAD. The existing last-subscriber test is a natural place to extend coverage with a slow native teardown and an independent responsiveness check.

Workaround tested

On this Mac we changed only non-recursive Git metadata directory watches in the server to poll once per second while subscribed. Git events elsewhere kept their normal behavior.

TestResult
Same isolated T3 service version with polling6 of 6 branch changes delivered. Client-observed cancellation took 1–3 ms. All 64 concurrent environment-discovery probes succeeded, the slowest in 25 ms.
Running background service with polling and a disposable Git repository12 of 12 branch changes delivered in 0.99–1.05 s. Cancellation took 1–28 ms. All 149 discovery probes succeeded, the slowest in 51 ms.
Authenticated connection through T3 Connect after the workaround6 of 6 WebSocket heartbeats received replies.

An upstream fix that keeps slow native teardown off the server's event loop would remove the need for the local version-specific workaround. The relevant v0.1.13 paths are watch creation and last-subscriber release. A comparable macOS watcher teardown in another project was addressed with on-demand polling.

  1. tanstack-source added labelsbug

Sign in to join this conversation.