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
Serverless Framework v3.30.1
Serverless Oflline v12.0.3 (today 2023-04-26, the last is v12.0.4)
Node.js v16.20.0
NPM v8.19.4
Python v3.9.16
Microsoft Windows 10
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.
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 from6
seconds to0
, instead of900
to0
.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 classFakeLambdaContext
of the Python lambda-runner. That is, the plugin is ignoring the lambda configuration provided inserverless.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 thetimeout
value specified inserverless.yml
, to0
. Then (when remaining time is0
), 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