Skip to content

Commit

Permalink
fix(idempotency): ensure in_progress_expiration field is set on Lambd…
Browse files Browse the repository at this point in the history
…a timeout. (#4773)

* fix(idempotency): fix timeout bug from #4759

* Adding comment

* Adding comment

---------

Co-authored-by: Leandro Damascena <[email protected]>
  • Loading branch information
sthulb and leandrodamascena authored Jul 19, 2024
1 parent d178865 commit ab5f7d8
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,10 @@ def save_inprogress(self, data: Dict[str, Any], remaining_time_in_millis: Option
payload_hash=self._get_hashed_payload(data=data),
)

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

0 comments on commit ab5f7d8

Please sign in to comment.