dherault / serverless-offline

Emulate AWS λ and API Gateway locally when developing your Serverless project
MIT License
5.19k stars 796 forks source link

Timeout is ignored in every Python function #1687

Open agustin-golmar opened 1 year ago

agustin-golmar commented 1 year ago

Bug Report

Current Behavior

We try to use the context.get_remaining_time_in_millis() method inside a Python lambda function. This is configured with a timeout of 900 seconds (15 minutes), but the value doesn't matter (it works the same with every posible value).

Every time the function run (reloading for every invocation using --reloadHandler, not reloading, or stopping the entire application and trying again), the context method reports a remaining time that decays from 6 seconds to 0, instead of 900 to 0.

Moreover, when remaining time reachs 0, it doesn't stops the execution.

Seeing the source code of Serverless Offline it seems that the magic 6 is the default value for the timeout in the class FakeLambdaContext of the Python lambda-runner. That is, the plugin is ignoring the lambda configuration provided in serverless.yml for the function.

Sample Code

Don't needed, its just the timeout value used in almost every function, and the function just prints the remaining time from the context method.

Expected behavior/code

We expect that the context method get_remaining_time_in_millis reports the right value in a Python lambda function, that is, a decay from the timeout value specified in serverless.yml, to 0. Then (when remaining time is 0), the function should stops processing the event/request received.

Environment

Possible Solution

There is a disconnection (maybe), between the Serverless Framework configuration, and the Python lambda-runner provided by Serverless Offline. I supposed that the parameters are not passing from one side to the other, so the runner uses the default timeout every time.

Thanks in advance. Agus