CLI synchronous invocation - Lamda invoked repeatedly

Hello,
I’ve been facing this issue: when synchronously invoking a lambda function from the Serverless CLI, if the function takes more than 285 seconds (unusual value for a default timeout…), the function is invoked again and again. All of the invocations get executed correctly, as confirmed from the CloudWatch logs, but the command never returns, at least not until an execution takes less then 285 seconds. Full command is is

AWS_CLIENT_TIMEOUT=900000 sls invoke -f functionName --stage stageName

Note:

  • Function timeout is set to 900s from the serveless.yaml file.
  • AWS_CLIENT_TIMEOUT variable is set 900000ms, and adding some logging in the serverless package, I’ve found out that the code just waits for the first request (in lib/aws/request.js stops at const result = await req.promise();, where req is imported from the aws-sdk package). No retries or logged errors.
  • The function is invoked inside a github action workflow, on Ubuntu.
  • From the aws doc:

For functions with a long timeout, your client might disconnect during synchronous invocation while it waits for a response. Configure your HTTP client, SDK, firewall, proxy, or operating system to allow for long connections with timeout or keep-alive settings.

It looks like something between the aws-sdk, the node http client and the OS is closing the connection after a while, and then try to reconnect repeating the request and triggering a new lambda execution.

I’m wondering if someone else experienced the same issue and if there might be a simple solution I’m missing, like setting variables from the CLI.