amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

AxiosError: read ECONNRESET

Open Sanoodia opened this issue 10 months ago • 3 comments

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

  1. created lambda by amplify cli
  2. add axios package
  3. use axios post call for updating or getting record by using appsync graphql api
  4. some time axios gives ECONNRESET error

Project Identifier

report-1712217332691.zip

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.

Sanoodia avatar Apr 04 '24 08:04 Sanoodia

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.

ykethan avatar Apr 04 '24 19:04 ykethan

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. (/opt/nodejs/node_modules/follow-redirects/index.js:38:24) at ClientRequest.emit (node:events:517:28) at ClientRequest.emit (node:domain:489:12) at TLSSocket.socketErrorListener (node:_http_client:501:9) at TLSSocket.emit (node:events:517:28) at TLSSocket.emit (node:domain:489:12) at Axios.request (/opt/nodejs/node_modules/axios/dist/node/axios.cjs:3876:41) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async getPaginatedData (/opt/envHelpers.js:84:22) at async Object.getLoadById (/var/task/sync_sdk.js:162:16) at async exports.handler (/var/task/index.js:464:30)

Sanoodia avatar Apr 08 '24 09:04 Sanoodia

@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.

ykethan avatar Apr 08 '24 19:04 ykethan

Closing the issue due to inactivity. Do reach out to us if you require any assistance.

ykethan avatar May 03 '24 15:05 ykethan

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.

github-actions[bot] avatar May 03 '24 15:05 github-actions[bot]