Skip to content

feat: retry starting a run on memory and concurrent-runs limits - #1091

Merged
vdusek merged 11 commits into
masterfrom
feat/wait-for-resources
Oct 7, 2026
Merged

vdusek merged 11 commits into
masterfrom
feat/wait-for-resources

Conversation

@vdusek

@vdusek vdusek commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Adds a waitForResources option to ActorClient.start()/call() and TaskClient.start()/call(). When set, a start that the API rejects with actor-memory-limit-exceeded or concurrent-runs-limit-exceeded is retried every 10 seconds. Orchestrators no longer need their own wait-and-retry loop.

  • true retries until the run starts. A number of seconds limits the retrying, after which the last 402 error is thrown.
  • Any other error is thrown right away. signal aborts the wait between attempts.
  • In call(), the retry time doesn't count toward waitSecs.
  • A Readable input can't be sent twice, so its start is never retried.
  • A run that asks for more memory than the account's whole memory limit gets the same actor-memory-limit-exceeded error and never starts, so true retries it forever. The API has no separate error type for that case. The docs call it out.

The Retries concept page gets a section with an example. The Python twin is apify/apify-client-python#1081 and uses the same design.

Closes #1074

✍️ Drafted by Claude Code

@vdusek vdusek added the t-tooling Issues with this label are in the ownership of the tooling team. label Sep 30, 2026
@vdusek vdusek self-assigned this Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ There are broken links in the documentation.

See more at https://github.com/apify/apify-client-js/actions/runs/37508511779#summary-112423238764

@vdusek
vdusek force-pushed the feat/wait-for-resources branch from 923c49f to 509812b Compare September 30, 2026 07:59
@B4nan
B4nan changed the base branch from v3 to master September 30, 2026 08:04
@B4nan B4nan mentioned this pull request Sep 30, 2026
12 tasks
@vdusek vdusek linked an issue Sep 30, 2026 that may be closed by this pull request
@vdusek
vdusek requested a review from barjin October 6, 2026 06:08
@vdusek
vdusek marked this pull request as ready for review October 6, 2026 06:08
@vdusek
vdusek requested a review from szaganek as a code owner October 6, 2026 06:08
@apify-service-account apify-service-account added the tested Temporary label used only programatically for some analytics. label Oct 6, 2026
Comment thread src/wait_for_resources.ts Outdated
vdusek added a commit to apify/apify-client-python that referenced this pull request Oct 7, 2026
Adds a `wait_for_resources` argument to `ActorClient.start`/`call` and
`TaskClient.start`/`call`, sync and async. When set, a start that the
API rejects with `actor-memory-limit-exceeded` or
`concurrent-runs-limit-exceeded` is retried every 10 seconds.
Orchestrators no longer need their own wait-and-retry loop.

- `True` retries until the run starts. A `timedelta` limits the
retrying, after which the last 402 error is raised.
- Any other error is raised right away.
- In `call`, the retry time doesn't count toward `wait_duration`.
- A file-like input is read into memory before the first attempt, so
every retry sends it whole.
- A run that asks for more memory than the account's whole memory limit
gets the same `actor-memory-limit-exceeded` error and never starts, so
`True` retries it forever. The API has no separate error type for that
case. The docs call it out.

The Retries concept page gets a section with sync and async examples.
The JS twin is apify/apify-client-js#1091 and uses the same design.

Closes: #1071

*✍️ Drafted by Claude Code*
@vdusek
vdusek merged commit d7c70ca into master Oct 7, 2026
8 of 9 checks passed
@vdusek
vdusek deleted the feat/wait-for-resources branch October 7, 2026 05:58
vdusek added a commit that referenced this pull request Oct 7, 2026
`dispatches().list() is async-iterable` failed on [a PR #1091
run](https://github.com/apify/apify-client-js/actions/runs/37508511779/job/112423238579)
with 0 dispatches collected. The test polled one listing read until the
dispatch showed up, then asserted on a second, separate read. Listing
endpoints read from Mongo secondaries, so the second read can hit a
lagging replica and come back empty.

The test now drains the iterator with `collectUntilPresent` (from #1090)
and waits for the id returned by `test()`, so the retried read is the
one it asserts on. It also checks for that specific dispatch, which is
stricter than "at least one".

*✍️ Drafted by Claude Code*
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.

Retry starting a run on memory and concurrent-runs limits

3 participants