Skip to content

Commit ab5f7d8

Browse files
fix(idempotency): ensure in_progress_expiration field is set on Lambda timeout. (aws-powertools#4773)
* fix(idempotency): fix timeout bug from aws-powertools#4759 * Adding comment * Adding comment --------- Co-authored-by: Leandro Damascena <[email protected]>
1 parent d178865 commit ab5f7d8

File tree

1 file changed

+4
-1
lines changed
  • aws_lambda_powertools/utilities/idempotency/persistence

1 file changed

+4
-1
lines changed

aws_lambda_powertools/utilities/idempotency/persistence/base.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,10 @@ def save_inprogress(self, data: Dict[str, Any], remaining_time_in_millis: Option
301301
payload_hash=self._get_hashed_payload(data=data),
302302
)
303303

304-
if remaining_time_in_millis:
304+
# When Lambda kills the container after timeout, the remaining_time_in_millis is 0, which is considered False.
305+
# Therefore, we need to check if remaining_time_in_millis is not None (>=0) to handle this case.
306+
# See: https://github.com/aws-powertools/powertools-lambda-python/issues/4759
307+
if remaining_time_in_millis is not None:
305308
now = datetime.datetime.now()
306309
period = datetime.timedelta(milliseconds=remaining_time_in_millis)
307310
timestamp = (now + period).timestamp()

0 commit comments

Comments
 (0)