fix(server): raise Windows ACP/stdio provider probe timeouts #5794
Closeddhiraj-ydv(GitHub profile, opens in a new tab)wants to merge 8 commits into
main fromrefs/pull/5794/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- docs/windows-provider-timeouts.md lines 49 to 49OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +29,21 @@29+### Timeouts (Windows / non-Windows)30+31+| Probe | Windows | Other |32+|-------|---------|-------|33+| Version (`--version`) | 15s | 4s |34+| Codex app-server auth | 45s | 15s |35+| Cursor `agent about` | 45s | 20s |36+| Cursor ACP discovery | 45s | 20s |37+| Grok ACP discovery | 45s | 20s |38+39+Env override for probe cwd (optional):40+41+`T3_PROVIDER_CWD`42+`T3CODE_PROVIDER_CWD`43+44+## How to verify45+46+```bash47+cd Documents/t3-code-fork/t3code48+pnpm install49+pnpm --filter @t3tools/server test -- src/provider/providerProbeTimeouts.test.tsapps/server/src/provider/providerProbeTimeouts.ts lines 68 to 69OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +49,21 @@49+ environment.T3_PROVIDER_CWD?.trim() || undefined,50+ environment.T3CODE_PROVIDER_CWD?.trim() || undefined,51+ safeProcessCwd(),52+ environment.USERPROFILE?.trim() || undefined,53+ environment.HOME?.trim() || undefined,54+ NodeOs.homedir(),55+ ];56+57+ for (const candidate of candidates) {58+ if (!candidate) continue;59+ try {60+ if (NodeFs.statSync(candidate).isDirectory()) {61+ return candidate;62+ }63+ } catch {64+ // try next65+ }66+ }67+68+ // Last resort: always a real directory on Node.69+ return NodePath.resolve(".");docs/windows-provider-timeouts.md lines 46 to 49OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +29,21 @@29+### Timeouts (Windows / non-Windows)30+31+| Probe | Windows | Other |32+|-------|---------|-------|33+| Version (`--version`) | 15s | 4s |34+| Codex app-server auth | 45s | 15s |35+| Cursor `agent about` | 45s | 20s |36+| Cursor ACP discovery | 45s | 20s |37+| Grok ACP discovery | 45s | 20s |38+39+Env override for probe cwd (optional):40+41+`T3_PROVIDER_CWD`42+`T3CODE_PROVIDER_CWD`43+44+## How to verify45+46+```bash47+cd Documents/t3-code-fork/t3code48+pnpm install49+pnpm --filter @t3tools/server test -- src/provider/providerProbeTimeouts.test.ts
- docs/windows-provider-timeouts.md line 54OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +34,21 @@34+| Codex app-server auth | 45s | 15s |35+| Cursor `agent about` | 45s | 20s |36+| Cursor ACP discovery | 45s | 20s |37+| Grok ACP discovery | 45s | 20s |38+39+Env override for probe cwd (optional):40+41+`T3_PROVIDER_CWD`42+`T3CODE_PROVIDER_CWD`43+44+## How to verify45+46+```bash47+cd Documents/t3-code-fork/t3code48+pnpm install49+pnpm --filter @t3tools/server test -- src/provider/providerProbeTimeouts.test.ts50+pnpm --filter @t3tools/server test -- src/provider/Layers/CursorProvider.test.ts51+pnpm --filter @t3tools/server test -- src/provider/Layers/ProviderRegistry.test.ts52+```53+54+Then run the desktop app from this fork and open a real project folder before checking Providers.
- apps/server/src/provider/providerProbeTimeouts.ts line 59OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +39,21 @@39+ * `process.cwd()` (empty welcome state). Spawning with an invalid cwd on40+ * Windows can hang instead of failing cleanly.41+ */42+export function resolveProviderProbeCwd(43+ preferred?: string | null,44+ environment: NodeJS.ProcessEnv = process.env,45+): string {46+ const candidates: Array<string | undefined> = [47+ preferred?.trim() || undefined,48+ environment.T3_PROVIDER_CWD?.trim() || undefined,49+ environment.T3CODE_PROVIDER_CWD?.trim() || undefined,50+ safeProcessCwd(),51+ environment.USERPROFILE?.trim() || undefined,52+ environment.HOME?.trim() || undefined,53+ NodeOs.homedir(),54+ ];55+56+ for (const candidate of candidates) {57+ if (!candidate) continue;58+ try {59+ if (NodeFs.statSync(candidate).isDirectory()) {
- apps/server/src/provider/providerProbeTimeouts.ts lines 15 to 18OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +1,18 @@1+import * as NodeFs from "node:fs";2+import * as NodeOs from "node:os";3+4+/**5+ * Provider status probes spawn local CLIs over stdio/ACP.6+ *7+ * On Windows, cold starts are substantially slower:8+ * - Cursor `agent about` commonly takes 7–12s (PowerShell + Node bootstrap)9+ * - Parallel Codex/Grok ACP handshakes compete for CPU/disk during desktop startup10+ * - Leaving stdin open can keep non-interactive probes waiting until timeout11+ *12+ * Timeouts below are deliberately higher on win32 so healthy installs are not13+ * reported as "Unavailable" during normal machine load.14+ */15+const isWindows = process.platform === "win32";16+17+/** Quick `--version` style probes. */18+export const PROVIDER_VERSION_PROBE_TIMEOUT_MS = isWindows ? 15_000 : 4_000;@@ -76,3 +82,6 @@7682 Effect.gen(function* () {7783 const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;7884 const child = yield* spawner.spawn(command);85+ // Close stdin immediately. Non-interactive probes (`agent about`, `grok --version`,86+ // etc.) can hang on Windows if stdin stays open waiting for EOF.87+ yield* Stream.run(Stream.empty, child.stdin).pipe(Effect.ignore);apps/server/src/provider/providerSnapshot.ts lines 26 to 29OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -18,6 +18,12 @@1818 import { createProviderVersionAdvisory } from "./providerMaintenance.ts";1919 import { collectUint8StreamText } from "../stream/collectUint8StreamText.ts";202021-export const DEFAULT_TIMEOUT_MS = 4_000;21+import {22+ PROVIDER_AUTH_PROBE_TIMEOUT_MS,23+ PROVIDER_VERSION_PROBE_TIMEOUT_MS,24+} from "./providerProbeTimeouts.ts";25+26+/** @deprecated Prefer PROVIDER_VERSION_PROBE_TIMEOUT_MS for new code. */27+export const DEFAULT_TIMEOUT_MS = PROVIDER_VERSION_PROBE_TIMEOUT_MS;2228 // Auth status checks involve disk/network lookups and can be slow on first run (especially Windows)23-export const AUTH_PROBE_TIMEOUT_MS = 10_000;29+export const AUTH_PROBE_TIMEOUT_MS = PROVIDER_AUTH_PROBE_TIMEOUT_MS;apps/server/src/provider/Layers/GrokProvider.ts line 49OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -41,5 +46,4 @@4146 optionDescriptors: [],4247 });434844-const VERSION_PROBE_TIMEOUT_MS = 4_000;45-const GROK_ACP_MODEL_DISCOVERY_TIMEOUT_MS = 15_000;49+const VERSION_PROBE_TIMEOUT_MS = PROVIDER_VERSION_PROBE_TIMEOUT_MS;@@ -0,0 +25,21 @@25+26+/** Cursor `agent about` (version + auth). Measured ~8–12s cold on Windows. */27+export const CURSOR_ABOUT_TIMEOUT_MS = isWindows ? 45_000 : 20_000;28+29+/** Cursor ACP model discovery after about succeeds. */30+export const CURSOR_ACP_MODEL_DISCOVERY_TIMEOUT_MS = isWindows ? 45_000 : 20_000;31+32+/** Grok `agent stdio` ACP initialize for model discovery. */33+export const GROK_ACP_MODEL_DISCOVERY_TIMEOUT_MS = isWindows ? 45_000 : 20_000;34+35+/**36+ * Resolve a usable working directory for provider status probes.37+ *38+ * Electron/desktop backends can end up with a non-directory or inaccessible39+ * `process.cwd()` (empty welcome state). Spawning with an invalid cwd on40+ * Windows can hang instead of failing cleanly.41+ */42+export function resolveProviderProbeCwd(43+ preferred?: string | null,44+ environment: NodeJS.ProcessEnv = process.env,45+): string {
- apps/server/src/provider/providerProbeTimeouts.ts lines 86 to 93OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +73,21 @@73+ try {74+ if (!NodeFs.statSync(path).isDirectory()) {75+ return false;76+ }77+ NodeFs.accessSync(path, NodeFs.constants.R_OK);78+ // Confirm we can actually enter/list — closer to spawn-with-cwd success.79+ NodeFs.readdirSync(path);80+ return true;81+ } catch {82+ return false;83+ }84+}85+86+function safeProcessCwd(): string | undefined {87+ try {88+ const cwd = process.cwd();89+ return cwd.trim().length > 0 ? cwd : undefined;90+ } catch {91+ return undefined;92+ }93+}
- apps/server/src/provider/providerProbeTimeouts.ts lines 136 to 139OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +119,21 @@119+ return candidate;120+ }121+ }122+123+ // Last resort: absolute directory independent of process.cwd().124+ return NodeOs.tmpdir();125+}126+127+/**128+ * Effect form: env from `HostProcessEnvironment` (unless overridden) and129+ * working directory from `HostProcessWorkingDirectory`.130+ */131+export const resolveProviderProbeCwd = Effect.fn("resolveProviderProbeCwd")(function* (132+ preferred?: string | null,133+ environment?: NodeJS.ProcessEnv,134+) {135+ const env = environment ?? (yield* HostProcessEnvironment);136+ const workingDirectory = yield* HostProcessWorkingDirectory.pipe(137+ Effect.map((cwd) => (cwd.trim().length > 0 ? cwd : undefined)),138+ Effect.catch(() => Effect.succeed(undefined as string | undefined)),139+ );
- apps/server/src/provider/providerProbeTimeouts.ts line 139OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +119,21 @@119+ return candidate;120+ }121+ }122+123+ // Last resort: absolute directory independent of process.cwd().124+ return NodeOs.tmpdir();125+}126+127+/**128+ * Effect form: env from `HostProcessEnvironment` (unless overridden) and129+ * working directory from `HostProcessWorkingDirectory`.130+ */131+export const resolveProviderProbeCwd = Effect.fn("resolveProviderProbeCwd")(function* (132+ preferred?: string | null,133+ environment?: NodeJS.ProcessEnv,134+) {135+ const env = environment ?? (yield* HostProcessEnvironment);136+ const workingDirectory = yield* HostProcessWorkingDirectory.pipe(137+ Effect.map((cwd) => (cwd.trim().length > 0 ? cwd : undefined)),138+ Effect.catch(() => Effect.succeed(undefined as string | undefined)),139+ );
- apps/server/src/provider/providerProbeTimeouts.ts line 145OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -0,0 +125,21 @@125+ return NodeOs.tmpdir();126+}127+128+/**129+ * Effect form: env from `HostProcessEnvironment` (unless overridden) and130+ * working directory from `HostProcessWorkingDirectory`.131+ */132+export const resolveProviderProbeCwd = Effect.fn("resolveProviderProbeCwd")(function* (133+ preferred?: string | null,134+ environment?: NodeJS.ProcessEnv,135+) {136+ const env = environment ?? (yield* HostProcessEnvironment);137+ // HostProcessWorkingDirectory is typed as infallible, but its defaultValue138+ // calls process.cwd() which can throw a defect when cwd is gone. Use Exit so139+ // defects fall through to home/tmpdir instead of failing the probe.140+ const workingDirectoryExit = yield* Effect.exit(141+ Effect.map(HostProcessWorkingDirectory, (cwd) => (cwd.trim().length > 0 ? cwd : undefined)),142+ );143+ const workingDirectory = Exit.isSuccess(workingDirectoryExit)144+ ? workingDirectoryExit.value145+ : undefined;
- apps/server/src/provider/providerProbeTimeouts.test.ts lines 35 to 35OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +15,21 @@15+ providerAuthProbeTimeoutMsFor,16+ providerVersionProbeTimeoutMsFor,17+ resolveProviderProbeCwd,18+ resolveProviderProbeCwdSync,19+} from "./providerProbeTimeouts.ts";20+21+describe("providerProbeTimeouts", () => {22+ it("uses higher probe timeouts on Windows via pure helpers", () => {23+ expect(cursorAboutTimeoutMsFor(true)).toBe(45_000);24+ expect(cursorAcpModelDiscoveryTimeoutMsFor(true)).toBe(45_000);25+ expect(grokAcpModelDiscoveryTimeoutMsFor(true)).toBe(45_000);26+ expect(providerAuthProbeTimeoutMsFor(true)).toBe(45_000);27+ expect(providerVersionProbeTimeoutMsFor(true)).toBe(15_000);28+29+ expect(cursorAboutTimeoutMsFor(false)).toBe(20_000);30+ expect(providerAuthProbeTimeoutMsFor(false)).toBe(15_000);31+ expect(providerVersionProbeTimeoutMsFor(false)).toBe(4_000);32+ });33+34+ it("Effect timeout values follow HostProcessPlatform", async () => {35+ const winAbout = await Effect.runPromise(apps/server/src/provider/Layers/CursorProvider.test.ts lines 337 to 337OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -333,4 +334,4 @@333334 status: "ready",334335 auth: { status: "authenticated", type: "Team", label: "Cursor Team Subscription" },335336 },336- discoveryWarning: "Cursor ACP model discovery timed out after 15000ms.",337+ discoveryWarning: `Cursor ACP model discovery timed out after ${cursorAcpModelDiscoveryTimeoutMsFor(process.platform === "win32")}ms.`,
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
bb9422ea-b5ba-4b8d-b6d4-784e48cb3dceYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share