`altool workspace compile` crashes with `IOException: The handle is invalid` when stdout is redirected (v17.0.2273547)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
Inizia da Workspace/WorkspaceCompileCommand.cs, in particolare da CompilationStatus.UpdateProgress() intorno alla riga 130, e riproduci il problema usando il comando con output reindirizzato indicato nell’issue. Verifica che la compilazione del workspace non vada più in crash quando stdout è reindirizzato, che produca un output di stato oppure salti in modo sicuro l’avanzamento interattivo e che conservi i log diagnostici.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
altool workspace compile throws an unhandled System.IO.IOException: The handle is invalid during CompilationStatus.UpdateProgress() when invoked from a non-interactive shell (pipes, CI runners, redirected output). The compilation never actually runs ÔÇö the crash happens almost immediately after the "Starting compilation" banner.
Environment
- AL Language extension: 17.0.2273547 (published 2026-04-01)
- OS: Windows 11 Pro for Workstations 10.0.26200
- .NET 8.0.25 runtime
- Shell: Git Bash (non-interactive / redirected stdout)
Reproduction
altool.exe workspace compile "path/to/workspace.code-workspace" 2>&1 | tail -80
Any redirection of stdout triggers it ÔÇö | tee, > file.log, piping through head/tail, or running inside a CI runner that captures the child process's streams.
Running the same command directly in a Windows Terminal / cmd.exe window with no redirection works correctly.
Expected
When stdout is not a TTY, workspace compile should disable the interactive progress display and emit plain line-by-line status output (or at least guard the Console.WindowWidth call and fall back to a sensible default). Competing CLI tools (e.g. dotnet build, msbuild) degrade gracefully under redirection.
Actual
Starting compilation of 2 project(s) with 22 parallel task(s)...
Log directory: C:\Repos\...\logs
Unhandled exception. System.IO.IOException: The handle is invalid.
at System.ConsolePal.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)
at System.ConsolePal.get_WindowWidth()
at Microsoft.Dynamics.Nav.Tool.CompilationStatus.UpdateProgress() in X:\source\Prod\altool\Workspace\WorkspaceCompileCommand.cs:line 130
at Microsoft.Dynamics.Nav.Tool.WorkspaceCompileCommand.<>c__DisplayClass17_0.<CompileGraphWithConcurrency>b__0(Object _) in X:\source\Prod\altool\Workspace\WorkspaceCompileCommand.cs:line 766
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.TimerQueueTimer.Fire(Boolean isThreadPool)
at System.Threading.TimerQueue.FireNextTimers()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Process exits with a non-zero code and no logs/ output is written (the directory is created but remains empty), so CI pipelines lose both the build result and the diagnostic trail.
Suggested fix
Guard the Console.WindowWidth call in CompilationStatus.UpdateProgress(). The standard .NET idiom is:
int width;
try { width = Console.IsOutputRedirected ? 120 : Console.WindowWidth; }
catch (IOException) { width = 120; }
Or simpler: skip progress updates entirely when Console.IsOutputRedirected == true.
Impact
Blocks altool workspace compile from use in automation scenarios ÔÇö CI pipelines, Git hooks, scripted multi-project builds, and agentic tooling that captures subprocess output. Any wrapper that redirects the child's stdout hits this immediately.
As a workaround, direct alc.exe invocation per project works fine under redirection ÔÇö only the workspace-level orchestration is affected.
Internal work item: AB#631155
- Lingua principale
- PowerShell
- Stelle
- 884
- Fork
- 285
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/AL
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 8/100
-
accepted
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
-
suggestion
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
accepted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
accepted
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Tutte le issue di microsoft/AL
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Gentleman-Programming/engram#1899 ·
I maintainer di solito rispondono entro 1 giorno
-
fit summary's per-chain loglik-eval table numbers chains from 0; every other artifact numbers from 1Apertaarea/cli effort/S kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
`burr` fails to start when the Python path has a space in itForse già presa @enekoreto l’ha presa oggi. Apertastatus/needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 5 giorni
-
`fnox set` ignores piped stdin when `--description` is given, saving the secret without a valueAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
complexity::1-low effort::1-hours priority::3-could
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
jumpingrivers/audit.connect#71 ·
I maintainer di solito rispondono entro 1 giorno