[Bug]: the CLI aborts with an unhandled Node exception when the workspace path is 259 characters or longer on Windows
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 18/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, typescript
Línea de trabajo
Start by reviewing packages/shared/src/windows-working-directory.ts and the reported call sites in packages/local-runtime-v2/src/service/workspace/operations/git-process.ts and packages/local-runtime/src/files/git-process.ts; then inspect the listed TUI entry points for how the error reaches users. Check test/windows-workspace-path.test.mjs and packages/shared/test/unit/windows-working-directory.test.ts. Done means the long-path failure is reported cleanly, the stdio socket errors are handled, and short paths still work. A prepared fix branch is already linked in the issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Labels requested: bug, needs-triage, cli
Product or interface
CLI - headless
The same code path serves the interactive TUI (runtime-agent-product.ts:130 → local-agent-config-builder.ts:250 → environment-prompt-composer.ts:24), so the TUI is affected as well — I report it under the headless CLI because that is how I reproduced it.
Version
- Installed:
mcode --version→ 0.7.8 - Published:
npm view @minimax-ai/code version→ 0.7.8 - Source paths verified against tag
v0.7.2(c6c7f28) and againstmain@2dd8829— the defect is present in both.
Node.js v24.18.0, pnpm 9.12.0.
Platform
Windows
OS version and architecture
Windows 11 x64 (build 26200), Node v24.18.0. LongPathsEnabled = 0x1 (see below — it does not help here).
Issue area
File / workspace / path / encoding
What happens
When the workspace directory reaches the Windows limit for a child process's working directory, the CLI does not report an error — it dies. The process terminates with an unhandled Node 'error' event and a raw stack trace, and --diagnostics-dir produces nothing usable (execution_started only), because the failure happens outside the runtime's error handling.
The failure is not a promise rejection, so the try/catch around the awaited call never sees it.
Steps to reproduce
-
Create a directory whose absolute path is 259 characters long (258 works, 259 fails).
-
Run:
mcode exec --cwd "<that directory>" --output-format text "Reply with exactly: PONG" -
Observe: no answer, but a Node stack trace.
Expected and actual behavior
- Expected: the run fails with a readable message (for example, that the workspace path exceeds the Windows limit for child processes) and exits in a controlled way with a documented exit code.
- Actual: the process aborts with
Error: read ENOTCONN(errno: -4053,code: 'ENOTCONN',syscall: 'read') on an unhandled'error'event of anet.Socket, exit code 1.
Measured threshold
Measured on this host by handing the working directory to execFile directly:
| working-directory length | result |
|---|---|
| 255 | OK |
| 258 | OK |
| 259 | spawn git ENOENT |
| 260, 261, 262, 265 | spawn git ENOENT |
The boundary matches Windows semantics: CreateProcessW limits lpCurrentDirectory to MAX_PATH, so 259 characters plus the terminating NUL is the last that fits.
Why LongPathsEnabled does not help
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled was 0x1 on this machine and the failure still occurred exactly at the boundary above. The limit applies to the child process's working directory, not to the file paths passed to it, so the long-path opt-in does not lift it.
Where it happens
// packages/local-runtime-v2/src/service/workspace/operations/git-process.ts:33-43
const result = await execFile(
'git',
['-c', 'core.quotePath=false', '--no-optional-locks', ...args],
{
cwd: resolve(workspace),
encoding: 'utf-8',
env: gitEnv(),
maxBuffer: GIT_MAX_BUFFER,
...
},
);
The call comes from packages/local-runtime-v2/src/service/workspace/operations/changes.ts:292 (isGitRepo → git(['rev-parse', '--is-inside-work-tree'])).
Node creates child.stdout / child.stderr as net.Socket instances over the pipe handles, and the execFile path attaches no 'error' listener to them. The first read therefore raises ENOTCONN as an 'error' event on a socket — not as a rejection — so it reaches the process as an uncaught exception.
Two further places have the same gap:
- the v1 layer:
packages/local-runtime/src/files/git-process.ts:19-24, called frompackages/local-runtime/src/files/api.ts:1411; - the streaming variant in the same file,
git-process.ts:62-115, which usesspawnand listens onchild.stdout/child.stderrwithout an'error'handler.
Redacted error summary
node:events:487
throw er; // Unhandled 'error' event
^
Error: read ENOTCONN
at tryReadStart (node:net:776:20)
at Socket._read (node:net:791:5)
at Readable.read (node:internal/streams/readable:741:12)
at Socket.read (node:net:845:39)
at new Socket (node:net:501:12)
at Object.Socket (node:net:366:41)
at createSocket (node:internal/child_process:337:14)
at ChildProcess.spawn (node:internal/child_process:475:23)
at spawn (node:child_process:796:9)
at execFile (node:child_process:349:17)
Emitted 'error' event on Socket instance at:
errno: -4053,
code: 'ENOTCONN',
syscall: 'read'
Suggested direction and prepared fix
The two things I would expect to be needed are both in a prepared branch: a readable diagnostic instead of a stack trace, and the missing error handling.
Branch: fix/git-process-long-workspace-path (commits 630e221 and e00af01, based on main @ 2dd8829)
- Preflight before the child is created. The check has to happen before the spawn, because the failure surfaces asynchronously on the stdio socket and cannot be caught by a
try/catcharound the promise. The new helperfindWindowsWorkingDirectoryOverflowinpackages/shared/src/windows-working-directory.tsreports the overflow, and the call sites inpackages/local-runtime-v2/src/service/workspace/operations/git-process.tsandpackages/local-runtime/src/files/git-process.tsreturn the error result before starting a child. - The stdio pipes get an
'error'listener. A child that fails to start leaves its pipes unconnected, and the sockets then reportread ENOTCONNon their own. Without a listener that terminates the host process — the spawn variant in the same file is covered by the same treatment. - The message reaches the user. The TUI and headless entry points (
packages/tui/src/cli/workspace-path.ts,packages/tui/src/headless/invocation.ts,packages/tui/src/cli/run-acp-command.ts,packages/tui/src/tui/launcher.ts) report the condition before the runtime starts.
On this host the behaviour changes from an uncaught exception to a controlled failure:
mcode exec --cwd "<260 characters>" --output-format text "Reply with exactly: PONG"
→ exit code 2
mcode exec failed: Workspace path exceeds the Windows limit for child processes (260 characters; maximum 258). …
A short path is unaffected (exit 0).
Tests
test/windows-workspace-path.test.mjs(registered in thewindowssuite) — the end-to-end behaviour through the CLI entry point: 10 tests green on this host.packages/shared/test/unit/windows-working-directory.test.ts— the overflow detection itself: 5 tests green.- Before the fix, the same test run ended in an uncaught
Error: read ENOTCONNand a non-zero exit code; after it, the run is green.
pnpm check:source and pnpm typecheck pass on the branch.
One place I did not change
packages/agent-tools/src/desktop/local-rg-runner.ts starts rg with the same working directory and has the same error class. It is outside the three places this issue describes, so I left it alone rather than widening the change — but it is worth a look, because the same overflow would apply there.
Before submitting
- I have searched existing issues.
- I have included my version and removed sensitive information.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2.3k
- Forks
- 315
- Merge medio
- 3 h 54 min
- PR fusionados (30 d)
- 9
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MiniMax-AI/minimax-code
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
MiniMax-AI/minimax-code#639 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
MiniMax-AI/minimax-code#636 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
MiniMax-AI/minimax-code#615 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
MiniMax-AI/minimax-code#556 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
MiniMax-AI/minimax-code#507 ·
Los mantenedores suelen responder en 1 día
Todos los issues de MiniMax-AI/minimax-code
Issues similares
-
area:api bug good first issue priority:high
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Doezer/Questarr#1486 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area:import difficulty:good-first good first issue help wanted priority:P1 roadmap size:S type:test
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Sergey-Bar/Penny#245 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
mihazs/lazysh#3377 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Approve the Cloudflare agent plugin for harness sessionsPosiblemente ocupada @joshtsch la tomó hoy. Abiertoenhancement ready-for-agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día