AWS Lambda "Task timed out after N seconds" in CI
The Lambda runtime killed the invocation because the handler ran past the configured Timeout. In a CI integration test this often means a downstream call hung, or an async handler never resolved its promise.
What this error means
The invoke response is an error and the logs end with "Task timed out after 3.00 seconds". No handler exception is thrown; the runtime simply stops the execution at the limit.
2026-06-30T12:00:03.512Z 1a2b3c4d Task timed out after 3.00 seconds
END RequestId: 1a2b3c4d
REPORT RequestId: 1a2b3c4d Duration: 3003.11 ms Billed Duration: 3000 msCommon causes
A downstream call blocks past the timeout
The handler waits on a network call (DB, HTTP, another AWS API) that is slow or unreachable in the CI environment, exceeding the function Timeout.
An async handler never settles
The handler returns a promise that never resolves (a missing callback, an unawaited task, or an open connection), so the runtime waits until the timeout.
How to fix it
Raise the timeout for the integration test
If the work legitimately takes longer, set a realistic Timeout for the function under test.
Properties:
Timeout: 30Make the handler resolve deterministically
- Ensure every async path is awaited and the handler returns or resolves.
- Add a client-side timeout to downstream calls so they fail fast instead of hanging.
- Mock slow external dependencies in the CI invoke.
const res = await fetch(url, { signal: AbortSignal.timeout(2000) });How to prevent it
- Set per-call timeouts on downstream requests below the function timeout.
- Always await async work so the promise settles.
- Stub external services in CI so latency is bounded.