Skip to content

fix: Limit timeout to minimum of 1 seconds when timeout='inherit'#1051

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

fix: Limit timeout to minimum of 1 seconds when timeout='inherit'#1051
Pijukatel merged 3 commits into
masterfrom
claude/actor-timeout-inheritance-gu27cl

Conversation

@Pijukatel

@Pijukatel Pijukatel commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Limit the minimum possible timeout to 1 second when using timeout='inherit'. 1s is the smallest possible API timeout value and will result in an almost certain timeout of the called actor.

Previously, the timeout value got set to 0, but the API interprets a timeout of 0 as no timeout at all.

claude added 2 commits July 16, 2026 06:30
…emaining

When `timeout='inherit'` was used and the current run was already past
its own timeout, the remaining time was clamped to zero and sent to the
API as `timeout=0`, which the platform treats as "no timeout" - the
other Actor run would get unlimited runtime instead of inheriting the
(exhausted) time budget. A positive sub-second remainder had the same
problem, as the API client truncates the timeout to whole seconds.

The remaining time is now rounded up to whole seconds, so it is never
truncated to zero, and when no time remains, `Actor.start`, `Actor.call`
and `Actor.call_task` skip the API call entirely, log a warning and
return `None`. Overloads keep the `Run` return type for calls that do
not use `timeout='inherit'`.

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
@Pijukatel Pijukatel requested a review from vdusek July 16, 2026 06:47
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.87%. Comparing base (573e3a3) to head (d7a5ae6).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1051      +/-   ##
==========================================
+ Coverage   91.77%   91.87%   +0.10%     
==========================================
  Files          50       50              
  Lines        3222     3225       +3     
==========================================
+ Hits         2957     2963       +6     
+ Misses        265      262       -3     
Flag Coverage Δ
e2e 35.56% <25.00%> (-0.01%) ⬇️
integration 57.33% <25.00%> (-0.03%) ⬇️
unit 83.22% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Pijukatel Pijukatel added the adhoc Ad-hoc unplanned task added during the sprint. label Jul 16, 2026
Comment thread tests/unit/actor/test_actor_helpers.py Outdated
Comment thread src/apify/_actor.py Outdated
@vdusek vdusek changed the title fix: Fix inherit timeout option when no timeout left fix: Don't start Actor with timeout='inherit' when no time remains Jul 16, 2026
@Pijukatel Pijukatel changed the title fix: Don't start Actor with timeout='inherit' when no time remains fix: Limit timeout to minimum of 1 seconds when timeout='inherit' Jul 16, 2026
@Pijukatel Pijukatel requested a review from vdusek July 16, 2026 09:10
@Pijukatel

Copy link
Copy Markdown
Contributor Author

A 1-second timeout might be more practical, as it retains the type and behavior consistency while having a kind of the same end-user behavior.

@vdusek vdusek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@Pijukatel Pijukatel merged commit 54e52e6 into master Jul 16, 2026
31 checks passed
@Pijukatel Pijukatel deleted the claude/actor-timeout-inheritance-gu27cl branch July 16, 2026 11:26
Pijukatel pushed a commit to apify/apify-sdk-js that referenced this pull request Jul 16, 2026
…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
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