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

optionally return non-zero error code when function run sees error #401

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jacobsteves
Copy link
Member

We want to support returning a non-zero error code anytime a module sees an error during a run. Unfortunately, since older versions of the Shopify CLI auto-update, we can't do this my default and make a breaking change. Instead, i opted to implement this change behind an option --non-zero-exit-code-for-module-errors. In the Shopify CLI, we can update new versions to start calling this flag.

When the flag isn't provided, nothing changes. When it is provided, we return exit code 1. Heres an example output with the flag:

 ✘  ~/src/github.com/Shopify/function-runner   js.return-error-when-module-errors  function-runner -f 'panic-configurable-fuel.wasm' -i 'input.json' -e run --non-zero-exit-code-for-module-errors
            Input
{ manually truncated }
            Logs

thread '<unnamed>' panicked at src/run.rs:24:5:
oh no - something terrible has happened
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error while executing at wasm backtrace:
    0: 0x17c4e - <unknown>!<wasm function 366>
    1: 0x84a9 - <unknown>!<wasm function 14>
    2: 0x13f68 - <unknown>!<wasm function 108>
    3: 0x17bf8 - <unknown>!<wasm function 355>
    4: 0x171b0 - <unknown>!<wasm function 243>
    5: 0x17182 - <unknown>!<wasm function 242>
    6: 0x57b8 - <unknown>!<wasm function 9>

        Invalid Output


         JSON Error

EOF while parsing a value at line 1 column 0

        Resource Limits


Input Size: 125.00KB
Output Size: 19.53KB
Instructions: 11M


     Benchmark Results

Name: panic-configurable-fuel.wasm
Linear Memory Usage: 1088KB
Instructions: 150.943K
Input Size: 4.98KB
Output Size: 0B
Module Size: 112KB


Error: The Function execution failed. Review the logs for more information.
 ✘  ~/src/github.com/Shopify/function-runner   js.return-error-when-module-errors  echo $?
1

src/main.rs Outdated
Ok(())
} else {
Err(anyhow!(
"The Function execution failed. Review the logs for more information."
Copy link
Member Author

Choose a reason for hiding this comment

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

we could have printed the error message here but I felt that was just too noisy since its displayed right above

@andrewhassan
Copy link
Contributor

I think we stopped auto-updating in this PR, which was released in the 3.65.0 version on August 2. I wonder if that's enough time that it would be okay to ship this PR as the default behaviour.

@nickwesselman Do you have an opinion on this?

Copy link
Contributor

@jeffcharles jeffcharles left a comment

Choose a reason for hiding this comment

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

Could we make a case for a breaking change for older versions of the Shopify CLI here? I would imagine we would want older versions of the CLI to error out in these cases. But if not, this seems fine.

src/main.rs Outdated Show resolved Hide resolved
src/engine.rs Outdated Show resolved Hide resolved

/// Return a non-zero exit code when a module error occurs during the function run.
#[clap(short = 'n', long)]
non_zero_exit_code_for_module_errors: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a pretty long flag name to me. Unfortunately I don't have a constructive suggestion for something more succinct.

@jacobsteves
Copy link
Member Author

Could we make a case for a breaking change for older versions of the Shopify CLI here?

I think it could be fair to make a case on that. It would make the changes here much nicer. I'll wait to see if Nick has an opinion there.

@jacobsteves jacobsteves force-pushed the js.return-error-when-module-errors branch from fcde9f1 to a59c72b Compare December 11, 2024 22:09
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.

3 participants