Skip to content

Commit 5d05f5e

Browse files
authored
[All] Prevent Fable from freezing when running a sub-process via --run (fix #3631) (#4344)
1 parent 7883ecc commit 5d05f5e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/Fable.Cli/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
* [Python] Fix `Array.length`, `.Length`, `Array.isEmpty`, and `ResizeArray.Count` to use `len()` instead of `.length` property for plain Python list interop (by @dbrattli)
1313
* [Python] Fix `Task<T>` pass-through returns not being awaited in if/else and try/with branches (by @dbrattli)
1414
* [Python] Fix `:? T as x` type test pattern in closures causing `UnboundLocalError` due to `cast()` shadowing outer variable (by @dbrattli)
15+
* [All] Prevent Fable from freezing when running a sub-process via `--run` (fix #3631) (by @MangelMaxime)
16+
* [All] Improve console width detection when rewritting console output (by @MangelMaxime)
1517

1618
## 5.0.0-alpha.23 - 2026-02-03
1719

src/Fable.Cli/Main.fs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -652,15 +652,25 @@ and FableCompiler(checker: InteractiveChecker, projCracked: ProjectCracked, fabl
652652

653653
match projCracked.CliArgs.Verbosity with
654654
| Verbosity.Silent -> ()
655-
| Verbosity.Verbose -> Console.Out.WriteLine(msg)
655+
| Verbosity.Verbose -> Log.always msg
656656
| Verbosity.Normal ->
657+
let hasRunProcess = Option.isSome projCracked.CliArgs.RunProcess
658+
659+
// If a process has been registered to run after compilation
660+
// We don't want to rewrite the console output because it can cause
661+
// a deadlock if the spwaned process rewrite the console output at the same time
662+
// See https://github.com/fable-compiler/Fable/issues/3631
663+
if hasRunProcess then
664+
Log.always msg
657665
// Avoid log pollution in CI. Also, if output is redirected don't try to rewrite
658666
// the same line as it seems to cause problems, see #2727
659-
if not isCi && not Console.IsOutputRedirected then
667+
else if not isCi && not Console.IsOutputRedirected then
668+
let maxWidth = Console.WindowWidth - 3 // for the "..." when message is too long
669+
660670
// If the message is longer than the terminal width it will jump to next line
661671
let msg =
662-
if msg.Length > 80 then
663-
msg.[..80] + "..."
672+
if msg.Length > maxWidth then
673+
msg.[..maxWidth] + "..."
664674
else
665675
msg
666676

0 commit comments

Comments
 (0)