amplify-cli
amplify-cli copied to clipboard
AxiosError: read ECONNRESET
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
18.12.0
Amplify CLI Version
12.8.2
What operating system are you using?
Window
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
Created a lambda function and im using axios call of curl operation on dynamodb using appsync graphql api.
Describe the bug
On peak time on lambda, axios call gives ECONNRESET on calling appsync graphql api
Expected behavior
It should perform action like update, delete or create
Reproduction steps
- created lambda by amplify cli
- add axios package
- use axios post call for updating or getting record by using appsync graphql api
- some time axios gives ECONNRESET error
Project Identifier
Log output
# Put your logs below this line
Additional information
Using Node 18x Commonjs in lambda and axios 1.6.8v here is my sample code
const axiosInstance = axios.create({
baseURL:process.env.API_CATHERD_GRAPHQLAPIENDPOINTOUTPUT,
headers: {
Authorization: "MY_TOKENXXX",
},
method: "post"
});
const updateDrDeck = async (actionInfo, _input, _num_attempt = 0 ) => {
console.log('_input',_input)
try {
if(_input?.cat?.includes("CT#") && _input?.id?.includes("CT#")){
logEvent({...actionInfo, ActionType: 1001, ActionInfo: JSON.stringify(actionInfo)},
process.env.STORAGE_PDEVENTS_NAME)
}
let response = await axiosInstance({
data: {
query: print(
gql`
${updateCatHerd}
`
),
variables: {
input: _input,
},
},
});
console.log('DD Updation response', response?.data, response?.errors);
if (response?.data?.data) console.log("Solution: ", response.data.data);
else console.log("Unable to update object", _input);
} catch (err) {
console.log("Error Updating DrDeck", err);
return err;
}
};
Before submitting, please confirm:
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.
Hey @Sanoodia, thank you for reaching. Is this occurring on a amplify mock function
?
If this is on the Lambda invocation on the console, implementing a error handling and retry logic may help in mitigating this behavior, refer to the Lambda documentation providing additional information. If this does not mitigate the issue, I would suggest reaching out to AWS technical support for Lambda for a deeper investigation.
here are the logs of my axio request
Error: read ECONNRESET
at AxiosError.from (/opt/nodejs/node_modules/axios/dist/node/axios.cjs:836:14)
at RedirectableRequest.handleRequestError (/opt/nodejs/node_modules/axios/dist/node/axios.cjs:3086:25)
at RedirectableRequest.emit (node:events:517:28)
at RedirectableRequest.emit (node:domain:489:12)
at eventHandlers.
@Sanoodia thank you for providing the log, the error read ECONNRESET
indicated an network/connection to a server was reset while the request was being made on the AWS Lambda. The AWS technical support for Lambda should be able to assist you in diving deeper on the service side.
Closing the issue due to inactivity. Do reach out to us if you require any assistance.
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.