Skip to content

feat(charging): track deduplicated charges under an idempotency key - #777

Merged
vladfrangu merged 1 commit into
masterfrom
feat/track-deduplicated-charges
Oct 21, 2026
Merged

vladfrangu merged 1 commit into
masterfrom
feat/track-deduplicated-charges

Conversation

@vladfrangu

@vladfrangu vladfrangu commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Closes #733. Mirrors apify/apify-sdk-python#1123.

A repeated Actor.charge() under an idempotencyKey seen in the last three minutes is now skipped locally as well as at the API, so the charging state and maxTotalChargeUsd accounting no longer drift from the platform.

  • Repeat under the same key reports the original chargedCount; a repeat naming a different event warns and reports zero.
  • Blank keys are rejected.
  • Local state is updated only after the API call succeeds, so a failed call retried under the same key counts once.
  • Synthetic and unknown events, which never reach the API, are tracked by key too.
  • The charging log dataset records the key.

Keys are kept in a small timestamped map pruned lazily, no new dependency.

[🤖] Claude Code using Fable 5.1

A repeated charge under a key seen in the last three minutes is skipped
locally as well as at the API, so the charging state no longer drifts
from the platform. Mirrors apify/apify-sdk-python#1123.

Closes #733
@vladfrangu
vladfrangu requested a review from szaganek as a code owner October 14, 2026 07:00
@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 14, 2026
@apify-service-account apify-service-account added the tested Temporary label used only programatically for some analytics. label Oct 14, 2026
@github-actions

Copy link
Copy Markdown

⚠️ There are broken links in the documentation.

See more at https://github.com/apify/apify-sdk-js/actions/runs/38525583727#summary-115725043212

@barjin barjin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you @vladfrangu , it seems to match the Python implementation in the important parts 👍 lgtm!

@vladfrangu
vladfrangu merged commit 11a8e5c into master Oct 21, 2026
11 of 13 checks passed
@vladfrangu
vladfrangu deleted the feat/track-deduplicated-charges branch October 21, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Track deduplicated charge events in ChargingManager

3 participants