amplify-backend
amplify-backend copied to clipboard
npx amplify sandbox contrl+c not handled properly
Environment information
System:
OS: Linux 6.7 Arch Linux
CPU: (24) x64 12th Gen Intel(R) Core(TM) i9-12900HX
Memory: 114.74 GB / 125.50 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
Yarn: 1.22.21 - /usr/bin/yarn
npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
pnpm: 8.14.1 - ~/.local/share/pnpm/pnpm
bun: Not Found
Watchman: Not Found
npmPackages:
@aws-amplify/backend: ^0.10.1 => 0.10.1
@aws-amplify/backend-cli: ^0.9.6 => 0.9.6
aws-amplify: ^6.0.12 => 6.0.12
aws-cdk: ^2.121.1 => 2.121.1
aws-cdk-lib: ^2.121.1 => 2.121.1
typescript: ^5.2.0 => 5.3.3
Description
npx amplify sandbox process not exiting gracefully on control + c. It behaves randomly incorrect
-
not listening to
control + cevent whennpx amplify sandboxis in error state -
control + cevent skips all the way without letting me respond to cleanup prompt
Most of the time this behavior happens when deploying sandbox env errors but occastionally noticed it on success as well.
I'm able to reproduce this by removing email from the defineAuth template, running amplify sandbox, which in turn produces an error. When attempting to ctrl+c I see the same issue
➜ p amplify sandbox
Unable to build Amplify backend. Check your backend definition in the `amplify` folder.
Caused By: Bundling asset amplify-amplifygen2-josef-sandbox-b6eddb8592/auth/SecretFetcherResourceProviderLambda/Code/Stage...
...3091233f22ea8ed624b7d06d4a2170d6d2865d8d59e2577d6547e30/index.js 204.2kb
⚡ Done in 83ms
/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/auth-construct-alpha/src/construct.ts:358
throw Error('At least one of email or phone must be enabled.');
^
Error: At least one of email or phone must be enabled.
at AmplifyAuth.AmplifyAuth.getUserPoolProps (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/auth-construct-alpha/src/construct.ts:358:13)
at AmplifyAuth (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/auth-construct-alpha/src/construct.ts:118:39)
at AmplifyAuthGenerator.generateContainerEntry (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend-auth/src/factory.ts:93:27)
at SingletonConstructContainer.getOrCompute (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend/src/engine/singleton_construct_container.ts:45:19)
at AmplifyAuthFactory.getInstance (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend-auth/src/factory.ts:67:31)
at <anonymous> (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend/src/backend_factory.ts:92:68)
at Array.forEach (<anonymous>)
at BackendFactory (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend/src/backend_factory.ts:88:40)
at defineBackend (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend/src/backend_factory.ts:120:19)
at <anonymous> (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/amplify/backend.ts:4:17)
Node.js v20.11.0
Subprocess exited with error 1
[Sandbox] Watching for file changes...
[Sandbox] Initializing...
[Sandbox] Executing command `deploy`
Unable to build Amplify backend. Check your backend definition in the `amplify` folder.
Caused By: Bundling asset amplify-amplifygen2-josef-sandbox-b6eddb8592/auth/SecretFetcherResourceProviderLambda/Code/Stage...
...3091233f22ea8ed624b7d06d4a2170d6d2865d8d59e2577d6547e30/index.js 204.2kb
⚡ Done in 13ms
/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/auth-construct-alpha/src/construct.ts:358
throw Error('At least one of email or phone must be enabled.');
^
Error: At least one of email or phone must be enabled.
at AmplifyAuth.AmplifyAuth.getUserPoolProps (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/auth-construct-alpha/src/construct.ts:358:13)
at AmplifyAuth (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/auth-construct-alpha/src/construct.ts:118:39)
at AmplifyAuthGenerator.generateContainerEntry (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend-auth/src/factory.ts:93:27)
at SingletonConstructContainer.getOrCompute (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend/src/engine/singleton_construct_container.ts:45:19)
at AmplifyAuthFactory.getInstance (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend-auth/src/factory.ts:67:31)
at <anonymous> (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend/src/backend_factory.ts:92:68)
at Array.forEach (<anonymous>)
at BackendFactory (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend/src/backend_factory.ts:88:40)
at defineBackend (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@aws-amplify/backend/src/backend_factory.ts:120:19)
at <anonymous> (/Users/josef/Documents/projects/aws-amplify/amplify-gen2-app/amplify/backend.ts:4:17)
Node.js v20.11.0
Subprocess exited with error 1
[Sandbox] Watching for file changes...
^C[Sandbox] Shutting down
? Would you like to delete all the resources in your sandbox environment (This
cannot be undone)? (y/N) [Sandbox] Shutting down
Error: setRawMode EIO
reproduced the second issue where the sandbox is hanging on to the process. I think my sso session expired and I saved a change in auth, then encountered the error below. When I encounter this I am forced to close my terminal.
The CloudFormation deployment has failed. Find more information in the CloudFormation AWS Console for this stack.
Caused By: ❌ Deployment failed: Error: Unable to resolve AWS account to use. It must be either configured when you define your CDK Stack, or through the environment
[Sandbox] Watching for file changes...
^C^X^C^C^C^C^C^C^C
^C^C^C
The issue is with the yarn not respecting SIGINT signal and just exiting right away leaving the children (sandbox process) hanging. because the parent process (yarn) is exited, the associated STDIO for child are also closed, so when the prompt tries to send something to stdout it crashes with the error setRawMode EIO.
I had better luck with yarn 1.22.22 where atleast the shell didn't hang and was still usable. but doesn't look like we can do anything until yarn fixes that bug.