Skip to content

fix: Fix inherit timeout units and no-timeout-left case - #667

Merged
Pijukatel merged 7 commits into
masterfrom
claude/actor-timeout-inheritance-gu27cl
Jul 16, 2026
Merged

fix: Fix inherit timeout units and no-timeout-left case#667
Pijukatel merged 7 commits into
masterfrom
claude/actor-timeout-inheritance-gu27cl

Conversation

@Pijukatel

@Pijukatel Pijukatel commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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.

claude added 3 commits July 16, 2026 05:57
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
@github-actions github-actions Bot added this to the 145th sprint - Tooling team milestone Jul 16, 2026
@github-actions github-actions Bot added t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics. labels Jul 16, 2026
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

⚠️ There are broken links in the documentation.

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

@Pijukatel Pijukatel added the adhoc Ad-hoc unplanned task added during the sprint. label Jul 16, 2026
…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
@Pijukatel
Pijukatel requested a review from B4nan July 16, 2026 07:33
…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
@Pijukatel Pijukatel changed the title fix: Fix inherit timeout units and no timeout left case fix: Fix inherit timeout units and no-timeout-left case Jul 16, 2026
@Pijukatel
Pijukatel marked this pull request as ready for review July 16, 2026 11:42
@Pijukatel

Copy link
Copy Markdown
Contributor Author

Parity with apify/apify-sdk-python#1051

@Pijukatel
Pijukatel requested a review from barjin July 16, 2026 12:35

@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 @Pijukatel !

Few naming nits to prevent similar confusion in the future, but nothing blocking 👍

Comment thread src/actor.ts Outdated
Comment thread src/actor.ts Outdated
Pijukatel and others added 2 commits July 16, 2026 14:51
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
@Pijukatel
Pijukatel merged commit d814901 into master Jul 16, 2026
8 checks passed
@Pijukatel
Pijukatel deleted the claude/actor-timeout-inheritance-gu27cl branch July 16, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. 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.

4 participants