dherault / dherault/serverless-offline

Scheduled Lambda timeout error 504 after execution

Open
#1,714 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.3k
Forks
811
Avg merge
2d 4h
Merged PRs (30d)
3

Description

## Bug Report

**Current Behavior**
A few seconds after a scheduled lambda is successfully executed an error occurs and will be displayed in console:
Failed to execute scheduled function: [emitStatistics] Error: Error: [504] - Lambda timeout.
It seems that serverless-offline can't handle the scheduled lambda in offline mode.
After deploying everything works fine.
There's a stackoverflow article with the same described problem:
https://stackoverflow.com/questions/76415087/serverless-offline-lambda-timeout-504

- file: serverless.yml
```yaml

plugins:
- serverless-offline

provider:
runtime: nodejs16.x
stage: offline

functions:
emitStatistics:
handler: src/handler/stats/handler.emitStatistics
events:
- schedule: rate(1 hour)
```

- file: handler.js
```js
export function emitStatistics(event: APIGatewayProxyEvent, context: Context) {
invokeWithDatabase(event, context, (conn) => handler(event, conn).emitAll());
}
```

**Expected behavior/code**
No error occurs after scheduled lambda is executed

**Environment**

- `serverless` version: 3.33.0
- `serverless-offline` version: 12.0.4
- `node.js` version: 16.20.0
- `OS`: macOS 13.4.1

**Additional context/Screenshots**
image

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the scheduled emitStatistics function from serverless.yml with the handler shown in handler.js, using serverless-offline in offline mode. Trace why the successful invocation later reports a 504 timeout, then verify that the same schedule completes without the console error while deployed behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cloud, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.