From dcabdb6b5483019352c4c524e070ea91f2113ce2 Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Sat, 14 Nov 2026 13:26:25 +0000 Subject: [PATCH 1/2] Retry heap-exhausted package builds with compacting GC --- app/src/App/CLI/Purs.purs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/App/CLI/Purs.purs b/app/src/App/CLI/Purs.purs index b32d1801..8446cfb8 100644 --- a/app/src/App/CLI/Purs.purs +++ b/app/src/App/CLI/Purs.purs @@ -206,6 +206,8 @@ isCompilerRaceCondition failure = case failure of -- | Compile PureScript source files with automatic retry for transient errors. -- | Retries up to 3 times when the "Unexpected end of JSON input" race condition occurs. +-- | Package builds that exhaust the heap get one serial, compacting attempt with +-- | the same heap limit, using the profile already used for whole package sets. compile :: forall r . { globs :: Array FilePath, profile :: CompileProfile, version :: Maybe Version, cwd :: Maybe FilePath } @@ -218,6 +220,11 @@ compile { globs, profile, version, cwd } = go 1 go attempt = do result <- Run.liftAff $ callCompiler { command: Compile { globs, profile }, version, cwd } case result of + Left err | isCompilerHeapExhaustion err -> case profile of + PackageBuild -> do + Log.warn "Compiler heap exhausted; retrying once with serial compilation and compacting GC (3 GiB heap limit)." + Run.liftAff $ callCompiler { command: Compile { globs, profile: PackageSetBuild }, version, cwd } + PackageSetBuild -> pure result Left err | isCompilerRaceCondition err && attempt < maxRetries -> do Log.warn $ "Compiler race condition detected (attempt " <> show attempt <> "/" <> show maxRetries <> "), retrying..." go (attempt + 1) From a4f5f8d0dee66ff62e221bd821d6412a499e4cab Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Sat, 14 Nov 2026 14:20:28 +0000 Subject: [PATCH 2/2] Avoid fixed limits in compiler retry descriptions --- app/src/App/CLI/Purs.purs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/App/CLI/Purs.purs b/app/src/App/CLI/Purs.purs index 8446cfb8..c6f2bad2 100644 --- a/app/src/App/CLI/Purs.purs +++ b/app/src/App/CLI/Purs.purs @@ -205,7 +205,7 @@ isCompilerRaceCondition failure = case failure of _ -> false -- | Compile PureScript source files with automatic retry for transient errors. --- | Retries up to 3 times when the "Unexpected end of JSON input" race condition occurs. +-- | Uses bounded retries when the "Unexpected end of JSON input" race condition occurs. -- | Package builds that exhaust the heap get one serial, compacting attempt with -- | the same heap limit, using the profile already used for whole package sets. compile @@ -222,7 +222,7 @@ compile { globs, profile, version, cwd } = go 1 case result of Left err | isCompilerHeapExhaustion err -> case profile of PackageBuild -> do - Log.warn "Compiler heap exhausted; retrying once with serial compilation and compacting GC (3 GiB heap limit)." + Log.warn "Compiler heap exhausted; retrying once with serial compilation and compacting GC at the same heap limit." Run.liftAff $ callCompiler { command: Compile { globs, profile: PackageSetBuild }, version, cwd } PackageSetBuild -> pure result Left err | isCompilerRaceCondition err && attempt < maxRetries -> do