Skip to content
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

fix: bail if purs exits non-ok #1285

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

cakekindel
Copy link
Contributor

@cakekindel cakekindel commented Sep 16, 2024

closes #1284

Description of the change

TODO

Checklist:

  • Added the change to the "Unreleased" section of the changelog
  • Added some example of the new feature to the README
  • Added a test for the contribution (if applicable)

P.S.: the above checks are not compulsory to get a change merged, so you may skip them. However, taking care of them will result in less work for the maintainers and will be much appreciated 😊

@cakekindel
Copy link
Contributor Author

root@3a9a77b24532:/app# node ../spago/bin/bundle.js build
Reading Spago workspace configuration...

✓ Selecting 14 packages to build:
  ...
  
Downloading dependencies...
Building...
‼ Failed to decode PsaResult at index '0': Unexpected end of JSON input
Json was: 

✘ purs exited with non-ok status code: BySignal "SIGKILL"

@cakekindel cakekindel changed the title draft: fix: bail if purs exits non-ok fix: bail if purs exits non-ok Sep 16, 2024
@cakekindel
Copy link
Contributor Author

hmm maybe dying isn't the right thing to do?

@f-f
Copy link
Member

f-f commented Sep 16, 2024

Uh, it looks like this uncovered a funny bug - CI is failing on this test, which should have never passed in the first place because we are supposed to fail in that condition

logSuccess "Build succeeded."
pure true
else if Array.all identity arrErrorsIsEmpty && not (Cmd.exitedOk result) then do
Copy link
Member

@f-f f-f Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this code structured as a series of if/else makes it extra confusing, let's move it to a case statement, e.g.

case Array.all identity arrErrorsIsEmpty, Cmd.exitedOk result of
  -- No errors, and 0 exit code
  true, true -> ...
  -- No errors, but non-zero exit code, so something's up
  true, false -> ...
  -- Compilation errors, print them out
  false, _ -> ...

Let's also try to catch the JSON decoding error earlier: the scenario we are trying to prevent here has err being an empty string. So let's try to not print the warning if that's the case, hopefully it will reduce the log noise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok no problem, ended up changing the output traversal to collect into an array of eithers to defer that logging and changed to a case expression

Copy link
Member

@f-f f-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good - could we add a test for this? The best way I can think of is to try to pass a nonexistent flag to purs.

@cakekindel
Copy link
Contributor Author

Sorry forgot about this. Will do tomorrow!

@f-f
Copy link
Member

f-f commented Oct 31, 2024

@cakekindel did you get around to finish this or shall I take care of the last bits? I'd like to get this merged ASAP before it gets out of date

@cakekindel
Copy link
Contributor Author

cakekindel commented Oct 31, 2024

@cakekindel did you get around to finish this or shall I take care of the last bits? I'd like to get this merged ASAP before it gets out of date

Sorry I forgot again, updated & added test!

  • Chose to have the test override the purs binary so that we can directly control its behavior rather than trying to provoke a specific behavior from purs
  • Failure message ("IF YOURE SEEING THIS ...") is searchable. I can only imagine how awful it would be to identify this test as the root cause of failures if someone tried to run them in parallel for example 🥴
  • Test fails on master e7a4e7e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"failed to decode PsaResult" when purs compile exits due to OOM
2 participants