amplify push timeout: An error occured during the push operation: Your socket connection to the server was not read from or written to within the timeout period
Describe the bug
For the past few days, as the schema started growing it has been almost impossible to reliably push any changes via amplify push --yes
The "Updating resources in the cloud. This may take a few minutes..." message only appears for one in several push attempts.
Some more logs/status updates relating to what it does at every step between compiling the schema and updating the resources in the cloud would be helpful.
I'm not sure if it's some sort of intermittent outage related to S3 or other resources amplify push might be using. This is not an internet problem on my end.
Running amplify api push results in a stack trace that mentions S3 as the reson for the timeout.
I have attached a screenshot below.
Error is:
Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
An error occured during the push operation: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
Amplify CLI Version
4.18.0
Expected behavior
Pushing should not timeout.
Screenshots

Desktop (please complete the following information):
node -v: 13.7.0 Win10 with WSL2 (Ubuntu)
Additional context
This started happening yesterday, presumably related to schema changes but I'm not sure. The processing step before it starts "Updating resources in the cloud. This may take a few minutes..." has been taking longer and longer.
Has been reported several times but the issues are closed:
https://github.com/aws-amplify/amplify-cli/issues/462 https://github.com/aws-amplify/amplify-cli/issues/501 https://github.com/aws-amplify/amplify-cli/issues/2121
Here's a screenshot of the error during amplify function push --yes:

Here's another screenshot of having to run the command 3 times:

@andreialecu This usually happens when Lambda sizes are too large, what's the size of your Lambda package that you are trying to deploy?
The size of the zip in the dist directory of the function is 1.5 megabytes.
It's this big because of node_modules dependencies. The unpacked size is around 6-7 MB.
@andreialecu I have been unable to reproduce it but as far as I know there could be a problem with the network. When a packet loss occurs S3 waits on the packet to be resent and waits, if the packets aren't sent in 20 seconds the connection is closed. I would recommend checking the network connection on the machine you are using to publish.

This issue is present in Amplify version 4.22 going forward.
amplify cli 4.24.3 does not work for me, error same as this issue. I downgraded to @aws-amplify/[email protected], it works as for now.
Same for me, with @aws-amplify/[email protected]. In my network connection there are some retransmissions due to signal quality. Uploading files to S3 through web console works, but if I try to use amplify push always get a socket timeout.
@ammarkarachi - how are you.. is it safe to say this has now been resolved. Or maybe being tracked by another issue reference
@KayIlory This should be available in the latest build let me know if it works for you.
Still happening to me in version 4.35.0. Command stuck at \ Uploading Files...8% and fails with socket timeout error
Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
An error occurred during the push operation: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
while pushing a lambda trigger function. It uses npm package node-html-to-image and hence it becomes a little bulky.
Still happening - why is this closed?
Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
An error occurred during the push operation: Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed.
Version: @aws-amplify/[email protected]
This is indeed still happening, I can no longer push with 4.52.
This is not an internet problem.
So I was able to figure out what the issue was ....
- Amplify Push
- Connections Opened ( S3/etc )
- Amplify Build + Your Build
- Build > S3 Socket Timeout time = Failure
+1. Also running into this. My feel is perhaps I have too many lambdas and too big of packages in each lambda for upload. I deploy through AWS Amplify as workaround. Perhaps the ongoing lambda layers rework will finally allow me to use lambda layers in the way I want.
Downgraded to @aws-amplify/[email protected] and it works! as @bernardnongpoh said
This is a pretty big issue since you are not able to deploy any complex app that has large set of changes.
I have not been able to reproduce this even with very large lambdas with a lot of dependencies. Does anyone have complete reproduction steps by any chance? Perhaps a repo that is affected by this?
@johnpc - Make complex gql complile + codegen + builds amplify:typescript take >15s.
I tried using "amplify:[functionName]": "echo [functionName] > /tmp/tmp.txt && sleep 20 && echo done > /tmp/tmp.txt" and saw that the step completed before the upload was initiated and the push was successful.