Skip to content

Commit 770ff04

Browse files
vdusekclaude
andcommitted
fix: Clamp negative timedelta in _get_remaining_time()
When `timeout_at` is already in the past, the subtraction produces a negative timedelta that would be passed to API calls via `start`, `call`, or `call_task` with `timeout='inherit'`. Clamp to zero instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 13b1fea commit 770ff04

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/apify/_actor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ def _get_default_exit_process(self) -> bool:
13981398
def _get_remaining_time(self) -> timedelta | None:
13991399
"""Get time remaining from the Actor timeout. Returns `None` if not on an Apify platform."""
14001400
if self.is_at_home() and self.configuration.timeout_at:
1401-
return self.configuration.timeout_at - datetime.now(tz=timezone.utc)
1401+
return max(self.configuration.timeout_at - datetime.now(tz=timezone.utc), timedelta(0))
14021402

14031403
self.log.warning(
14041404
'Using `inherit` or `RemainingTime` argument is only possible when the Actor'

0 commit comments

Comments
 (0)