Repository navigation
Retry package-set heap exhaustion with clean compiler output #815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -263,12 +263,21 @@ handle env = case _ of | |
| compileInstalledPackages :: Version -> Run _ (Either CompilerFailure String) | ||
| compileInstalledPackages compiler = do | ||
| Log.debug "Compiling installed packages..." | ||
| Purs.compile | ||
| { globs: [ Path.concat [ Path.basename packagesWorkDir, "**/*.purs" ] ] | ||
| , profile: Purs.PackageSetBuild | ||
| , version: Just compiler | ||
| , cwd: Just env.workdir | ||
| } | ||
| let | ||
| compile = Purs.compile | ||
| { globs: [ Path.concat [ Path.basename packagesWorkDir, "**/*.purs" ] ] | ||
| , profile: Purs.PackageSetBuild | ||
| , version: Just compiler | ||
| , cwd: Just env.workdir | ||
| } | ||
| result <- compile | ||
| case result of | ||
| Left err | Purs.isCompilerHeapExhaustion err -> do | ||
| Log.warn "Compiler heap exhausted; clearing package-set output and retrying once." | ||
| -- Keep the backup intact so a failed retry can still roll back. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment is above a line that removes a folder. why do we talk about backups? |
||
| FS.Extra.remove outputWorkDir | ||
| compile | ||
| _ -> pure result | ||
|
|
||
| attemptChanges :: Version -> PackageSet -> ChangeSet -> Run _ (Either CompilerFailure PackageSet) | ||
| attemptChanges compiler (PackageSet set) changes = do | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,6 +54,17 @@ spec = do | |
| let err = UnknownError "Some prefix text\nJSON: Unexpected end of JSON input\nSome suffix" | ||
| Purs.isCompilerRaceCondition err `Assertions.shouldEqual` true | ||
|
|
||
| Spec.it "Recognizes heap exhaustion without treating its empty JSON output as a race" do | ||
| let | ||
| err = UnknownError $ String.joinWith "\n" | ||
| [ "purs: Heap exhausted;" | ||
| , "purs: Current maximum heap size is 3221225472 bytes (3072 MB)." | ||
| , "JSON: Unexpected end of JSON input" | ||
| ] | ||
| Purs.isCompilerHeapExhaustion err `Assertions.shouldEqual` true | ||
| Purs.isCompilerRaceCondition err `Assertions.shouldEqual` false | ||
| Purs.isCompilerHeapExhaustion (UnknownError "JSON: Unexpected end of JSON input") `Assertions.shouldEqual` false | ||
|
|
||
|
Comment on lines
+57
to
+67
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this test is very useful. We are checking that a function that matches a certain string can in fact match the same string. |
||
| Spec.it "Does not detect race condition for normal UnknownError" do | ||
| let err = UnknownError "Some other compiler error message" | ||
| Purs.isCompilerRaceCondition err `Assertions.shouldEqual` false | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm intentionally classifying the unknown text rather than expanding the compiler failure sum type, as this information is really only needed in niche scenarios and not something every consumer of the compiler failure enum should need to think about
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense. can we replace the (not very useful) docstring with a comment that contains this note?