diff --git a/src/Fable.Cli/CHANGELOG.md b/src/Fable.Cli/CHANGELOG.md index 965c110ca3..d89d6adeff 100644 --- a/src/Fable.Cli/CHANGELOG.md +++ b/src/Fable.Cli/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +* [All] Fixed Fable compiler hanging on some errors (#3842) (by @ncave) * [JS/TS] Fixed DateTime.MinValue, DateTime.MaxValue (#3836) (by @ncave) ## 4.19.0 - 2024-06-10 diff --git a/src/Fable.Cli/Entry.fs b/src/Fable.Cli/Entry.fs index d889896734..0b81bff9b0 100644 --- a/src/Fable.Cli/Entry.fs +++ b/src/Fable.Cli/Entry.fs @@ -385,7 +385,7 @@ type Runner = let startCompilation () = State.Create(cliArgs, ?watchDelay = watchDelay, useMSBuildForCracking = useMSBuildForCracking) - |> startCompilation + |> startCompilationAsync |> Async.RunSynchronously return! diff --git a/src/Fable.Cli/Main.fs b/src/Fable.Cli/Main.fs index 0cae26d7ab..a7e8dd1069 100644 --- a/src/Fable.Cli/Main.fs +++ b/src/Fable.Cli/Main.fs @@ -1250,7 +1250,7 @@ let private compilationCycle (state: State) (changes: ISet) = type FileWatcherMsg = | Changes of timeStamp: DateTime * changes: ISet -let startCompilation state = +let startCompilationAsync state = async { try let state = diff --git a/src/Fable.Transforms/State.fs b/src/Fable.Transforms/State.fs index 4fb11c2bb6..8e621dd1c8 100644 --- a/src/Fable.Transforms/State.fs +++ b/src/Fable.Transforms/State.fs @@ -139,7 +139,12 @@ type ImplFile = // add all entities to the entity cache let entities = Dictionary() - let declarations = file.Declarations + + let declarations = + try + file.Declarations // this may throw + with _ex -> + [] FSharp2Fable.Compiler.getRootFSharpEntities declarations |> loop entities diff --git a/tests/Integration/Compiler/Util/Compiler.fs b/tests/Integration/Compiler/Util/Compiler.fs index 919b855bed..7d73591e71 100644 --- a/tests/Integration/Compiler/Util/Compiler.fs +++ b/tests/Integration/Compiler/Util/Compiler.fs @@ -69,7 +69,7 @@ module Compiler = let result = state - |> startCompilation + |> startCompilationAsync |> Async.RunSynchronously match result with