fix: Fix inherit timeout units and no-timeout-left case - #667
Merged
Conversation
When starting another Actor run with `timeout: 'inherit'`, the remaining time of the current run was computed in milliseconds and passed directly to apify-client, whose `timeout` option is in seconds. The started run thus received a timeout 1000x longer than intended. The remaining time is now converted to seconds (rounded up, so that a sub-second remainder does not become 0, which means "no timeout") and clamped to a minimum of 0, matching the Python SDK behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E5mT2U8shnNpysaq8NdtZe
…emaining When `timeout: 'inherit'` is used and the current run is already past its own timeout, the resolved timeout would be 0, which the API treats as "no timeout" - the other Actor run would get unlimited runtime instead of inheriting the (exhausted) time budget. `Actor.start()`, `Actor.call()` and `Actor.callTask()` now skip the API call entirely in that case, log a warning and return `undefined`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E5mT2U8shnNpysaq8NdtZe
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E5mT2U8shnNpysaq8NdtZe
|
See more at https://github.com/apify/apify-sdk-js/actions/runs/29500001181#summary-87626264389 |
…un result `Actor.start()`, `Actor.call()` and `Actor.callTask()` (instance and static) now declare three overloads: calls with a numeric or omitted timeout keep returning `Promise<ActorRun>`, `timeout: 'inherit'` returns `Promise<ActorRun | undefined>` to surface the possible skip, and a catch-all signature keeps un-narrowed options unions honest with the `| undefined` return type. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E5mT2U8shnNpysaq8NdtZe
…ng the run Match the approach merged in the Python SDK (apify/apify-sdk-python#1051): when `timeout: 'inherit'` is used and the current run is already past its own timeout, the started run now gets the smallest API-accepted timeout of 1 second (resulting in an almost certain timeout of the started run) instead of being skipped. The API treats a timeout of 0 as no timeout at all, which is why the value is never allowed to reach 0. This removes the skip behavior, the `| undefined` return types and the overloads - `Actor.start()`, `Actor.call()` and `Actor.callTask()` always return the run object again. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E5mT2U8shnNpysaq8NdtZe
inherit timeout units and no timeout left caseinherit timeout units and no-timeout-left case
Pijukatel
marked this pull request as ready for review
July 16, 2026 11:42
Contributor
Author
|
Parity with apify/apify-sdk-python#1051 |
barjin
approved these changes
Jul 16, 2026
barjin
left a comment
Member
There was a problem hiding this comment.
Thank you @Pijukatel !
Few naming nits to prevent similar confusion in the future, but nothing blocking 👍
Co-authored-by: Jindřich Bär <jindrichbar@gmail.com>
The review suggestions renamed `getRemainingTime` to `getRemainingTimeSecs` and the local constant to `MINIMUM_API_TIMEOUT_SECS`, but the call sites still used the old names. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E5mT2U8shnNpysaq8NdtZe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Timeout units:
Remaining time was calculated in milliseconds, while API accepts a timeout in seconds. This led to incorrect timeout values being passed to the API. Properly pass the timeout in seconds to the API.
No timeout left case:
Limit the minimal timeout to 1s, as the API interprets a timeout of 0 as no timeout at all.