Timeout Troubles? Fixing your mysterious AWS Lambda time-out’s when you can’t log anything

tl;dr: Did you provision the function enough memory?

Marco Lüthy
2 min readMar 28, 2023

Here’s the scenario: you’ve likely made some changes and deployed a new version of your AWS Lambda function handler. Maybe you upgraded a dependency, or you moved from Node.js 16 to Node.js 18. Now the Lambda task just keeps timing out — “Task timed out after X seconds”. Your logs in CloudWatch look something like this:

💩

You tried adding some logging right at the start of your handler’s code (e.g. with console.log) but it never shows up in the logs.

import stuff './from/wherever'
import aBunchMoreStuff './from/more/stuff'

export async function handler() {
console.log('wtf.')

// ... the rest of your code
}

It feels like Lambda never gets as far as running your handler code. WTF is going on?

Take a closer look at your CloudWatch log lines:

INIT_START Runtime Version: nodejs:18.v5 Runtime Version ARN: arn:aws:lambda:us-east-1::runtime:b97ad873eb5228db2e7d5727cd116734cc24c92ff1381739c4400c095404a2d3
2023-03-22T12:38:06.349Z 5cc78783-46fa-5df8-a237-db17be55a23c Task timed out after 32.00 seconds

END RequestId: 5cc78783-46fa-5df8-a237-db17be55a23c
REPORT RequestId…

--

--

Marco Lüthy

Hi there! I’m Marco. I write mostly about software development, sometimes about books I’ve read, and occasionally something else to keep things interesting.