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(amplify-cli-core): gracefully handle execa race condition #13692

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

rtpascual
Copy link
Contributor

@rtpascual rtpascual commented Apr 3, 2024

Description of changes

When execa handles a hooks file that executes very fast, we have a race condition where execa will try to pipe inputs to the child process's stdin after the process finishes causing an EPIPE error (Refer to sindresorhus/execa#474).

The change is to not have execa reject initially so we can determine what to do:

  • If the hooks file executed successfully (child process exit code is 0), then we continue execution.
  • If not, then we go through our existing error handling.

Also updated how we pipe stdout for the child process, this caused the misconception that the hooks file was not running at all (no echo in the hooks file is presented).

Issue #, if available

Description of how you validated changes

Added unit tests and manually tested with the following pre-push and post-push hooks files:

// pre-push.sh
echo "prepush hook"
// post-push.sh
echo "postpush hook"

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)
  • New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
  • Pull request labels are added

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rtpascual rtpascual requested a review from a team as a code owner April 3, 2024 17:51
@rtpascual
Copy link
Contributor Author

l_function_3a_init_special_case_http_migration E2E test, go function tests › add go hello world function and invoke in the cloud, failed and is being addressed as part of #13671

@rtpascual rtpascual merged commit dcafcb2 into aws-amplify:dev Apr 3, 2024
5 of 6 checks passed
@rtpascual rtpascual deleted the handle-execa-race-condition branch April 5, 2024 16:44
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.

None yet

3 participants