diff --git a/src/firebase_functions/options.py b/src/firebase_functions/options.py index ee084cbe..cf327889 100644 --- a/src/firebase_functions/options.py +++ b/src/firebase_functions/options.py @@ -869,6 +869,7 @@ def _endpoint( schedule=self.schedule, timeZone=time_zone, retryConfig=retry_config, + attemptDeadlineSeconds=self.timeout_sec, ), } return _manifest.ManifestEndpoint(**_typing.cast(dict, kwargs_merged)) diff --git a/src/firebase_functions/private/manifest.py b/src/firebase_functions/private/manifest.py index 7672a9f5..7a9a9c13 100644 --- a/src/firebase_functions/private/manifest.py +++ b/src/firebase_functions/private/manifest.py @@ -125,6 +125,7 @@ class ScheduleTrigger(_typing.TypedDict): schedule: str | _params.Expression[str] timeZone: str | _params.Expression[str] | _util.Sentinel | None retryConfig: RetryConfigScheduler | None + attemptDeadlineSeconds: int | _params.Expression[int] | _util.Sentinel | None class BlockingTriggerOptions(_typing.TypedDict): diff --git a/tests/test_scheduler_fn.py b/tests/test_scheduler_fn.py index f3ad92f1..8c7dc5c00 100644 --- a/tests/test_scheduler_fn.py +++ b/tests/test_scheduler_fn.py @@ -47,6 +47,18 @@ def test_on_schedule_decorator(self): self.assertEqual(endpoint.scheduleTrigger.get("schedule"), schedule) self.assertEqual(endpoint.scheduleTrigger.get("timeZone"), tz) + def test_on_schedule_with_timeout(self): + """ + Tests that attemptDeadlineSeconds is set to timeoutSeconds. + """ + decorated_func = scheduler_fn.on_schedule( + schedule="* * * * *", + timeout_sec=120, + )(Mock(__name__="example_func")) + endpoint = decorated_func.__firebase_endpoint__ + self.assertEqual(endpoint.timeoutSeconds, 120) + self.assertEqual(endpoint.scheduleTrigger.get("attemptDeadlineSeconds"), 120) + def test_on_schedule_call(self): """ Tests to ensure the decorated function is called correctly