Skip to content

Conversation

@ConnorKirk
Copy link
Contributor

Summary

This PR adds support for Durable Functions to the Idempotency Utility.
In testing, we discovered that the Idempotency utility did not work with Durable Functions when they suspended and replayed. This is because the replay appeared like a duplicate, so raised an IdempotencyAlreadyInProgressError

We use the DurableMode property on the DurableContext object to track if this is a new execution, or a replay of an prior execution.

The behaviour of the handler is the same, except when it's a previously seen payload "in progress" and the DurableMode is REPLAY_MODE. Then the execution will continue, where previously it would have raised the error IdempotencyAlreadyInProgressError

Changes

  • Check the context type in makeIdempotent. If it's a durable context, extract the lambda context and the DurableMode.
  • Add a new optional parameter to the IdempotentHandler.handler() method, durableMode.
  • Update IdempotentHandler to check if the execution is in REPLAY_MODE when IdempotencyAlreadyInProgressError is thrown.
  • Add tests to IdempotentHandler.test.js
  • Add test to makeIdempotent.test.js

Notes

  • It's missing e2e tests. These will be added in a future PR.
  • We use context.getTimeInMillis() to calculate the expiry time of the INPROGRESS status. Duplicate payloads received after that expiry time will be allowed. In a durable execution, the length of the workflow can be up to 1 year, across multiple lambda invocations. This is longer than the maximum 15 minutes that an INPROGRESS status can currently have. Idempotency records for long running workflows will not be protected from duplicate invokes beyond the first 15 minutes of their life.

Please add the issue number below, if no issue is present the PR might get blocked and not be reviewed

Issue number: closes #4831


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@boring-cyborg boring-cyborg bot added idempotency This item relates to the Idempotency Utility tests PRs that add or change tests labels Dec 2, 2025
@pull-request-size pull-request-size bot added the size/L PRs between 100-499 LOC label Dec 2, 2025
@ConnorKirk ConnorKirk self-assigned this Dec 2, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 2, 2025

Copy link
Contributor

@dreamorosi dreamorosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@dreamorosi dreamorosi merged commit 4dc0798 into main Dec 2, 2025
50 checks passed
@dreamorosi dreamorosi deleted the feat/idempotency_replay branch December 2, 2025 18:33
@ConnorKirk
Copy link
Contributor Author

I've opened #4839 to track the E2E test task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

idempotency This item relates to the Idempotency Utility size/L PRs between 100-499 LOC tests PRs that add or change tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: add support for durable function in Idempotency Utility

2 participants