@@ -3826,6 +3826,40 @@ def fetch_result() -> dict:
38263826 assert fetch_attempts ["count" ] == 0
38273827
38283828
3829+ def test_wait_for_job_result_retries_overlong_numeric_bytes_status_errors ():
3830+ status_attempts = {"count" : 0 }
3831+ fetch_attempts = {"count" : 0 }
3832+
3833+ def get_status () -> str :
3834+ status_attempts ["count" ] += 1
3835+ if status_attempts ["count" ] < 3 :
3836+ raise HyperbrowserError (
3837+ "oversized status metadata" ,
3838+ status_code = b"4000000000000" , # type: ignore[arg-type]
3839+ )
3840+ return "completed"
3841+
3842+ def fetch_result () -> dict :
3843+ fetch_attempts ["count" ] += 1
3844+ return {"ok" : True }
3845+
3846+ result = wait_for_job_result (
3847+ operation_name = "sync wait helper status oversized numeric-bytes retries" ,
3848+ get_status = get_status ,
3849+ is_terminal_status = lambda value : value == "completed" ,
3850+ fetch_result = fetch_result ,
3851+ poll_interval_seconds = 0.0001 ,
3852+ max_wait_seconds = 1.0 ,
3853+ max_status_failures = 5 ,
3854+ fetch_max_attempts = 5 ,
3855+ fetch_retry_delay_seconds = 0.0001 ,
3856+ )
3857+
3858+ assert result == {"ok" : True }
3859+ assert status_attempts ["count" ] == 3
3860+ assert fetch_attempts ["count" ] == 1
3861+
3862+
38293863def test_wait_for_job_result_does_not_retry_broken_executor_status_errors ():
38303864 status_attempts = {"count" : 0 }
38313865 fetch_attempts = {"count" : 0 }
@@ -4427,6 +4461,34 @@ def fetch_result() -> dict:
44274461 assert fetch_attempts ["count" ] == 3
44284462
44294463
4464+ def test_wait_for_job_result_retries_overlong_numeric_bytes_fetch_errors ():
4465+ fetch_attempts = {"count" : 0 }
4466+
4467+ def fetch_result () -> dict :
4468+ fetch_attempts ["count" ] += 1
4469+ if fetch_attempts ["count" ] < 3 :
4470+ raise HyperbrowserError (
4471+ "oversized status metadata" ,
4472+ status_code = b"4000000000000" , # type: ignore[arg-type]
4473+ )
4474+ return {"ok" : True }
4475+
4476+ result = wait_for_job_result (
4477+ operation_name = "sync wait helper fetch oversized numeric-bytes retries" ,
4478+ get_status = lambda : "completed" ,
4479+ is_terminal_status = lambda value : value == "completed" ,
4480+ fetch_result = fetch_result ,
4481+ poll_interval_seconds = 0.0001 ,
4482+ max_wait_seconds = 1.0 ,
4483+ max_status_failures = 5 ,
4484+ fetch_max_attempts = 5 ,
4485+ fetch_retry_delay_seconds = 0.0001 ,
4486+ )
4487+
4488+ assert result == {"ok" : True }
4489+ assert fetch_attempts ["count" ] == 3
4490+
4491+
44304492def test_wait_for_job_result_retries_request_timeout_fetch_errors ():
44314493 fetch_attempts = {"count" : 0 }
44324494
@@ -4639,6 +4701,43 @@ async def fetch_result() -> dict:
46394701 asyncio .run (run ())
46404702
46414703
4704+ def test_wait_for_job_result_async_retries_overlong_numeric_bytes_status_errors ():
4705+ async def run () -> None :
4706+ status_attempts = {"count" : 0 }
4707+ fetch_attempts = {"count" : 0 }
4708+
4709+ async def get_status () -> str :
4710+ status_attempts ["count" ] += 1
4711+ if status_attempts ["count" ] < 3 :
4712+ raise HyperbrowserError (
4713+ "oversized status metadata" ,
4714+ status_code = b"4000000000000" , # type: ignore[arg-type]
4715+ )
4716+ return "completed"
4717+
4718+ async def fetch_result () -> dict :
4719+ fetch_attempts ["count" ] += 1
4720+ return {"ok" : True }
4721+
4722+ result = await wait_for_job_result_async (
4723+ operation_name = "async wait helper status oversized numeric-bytes retries" ,
4724+ get_status = get_status ,
4725+ is_terminal_status = lambda value : value == "completed" ,
4726+ fetch_result = fetch_result ,
4727+ poll_interval_seconds = 0.0001 ,
4728+ max_wait_seconds = 1.0 ,
4729+ max_status_failures = 5 ,
4730+ fetch_max_attempts = 5 ,
4731+ fetch_retry_delay_seconds = 0.0001 ,
4732+ )
4733+
4734+ assert result == {"ok" : True }
4735+ assert status_attempts ["count" ] == 3
4736+ assert fetch_attempts ["count" ] == 1
4737+
4738+ asyncio .run (run ())
4739+
4740+
46424741def test_wait_for_job_result_async_does_not_retry_broken_executor_status_errors ():
46434742 async def run () -> None :
46444743 status_attempts = {"count" : 0 }
@@ -5297,6 +5396,37 @@ async def fetch_result() -> dict:
52975396 asyncio .run (run ())
52985397
52995398
5399+ def test_wait_for_job_result_async_retries_overlong_numeric_bytes_fetch_errors ():
5400+ async def run () -> None :
5401+ fetch_attempts = {"count" : 0 }
5402+
5403+ async def fetch_result () -> dict :
5404+ fetch_attempts ["count" ] += 1
5405+ if fetch_attempts ["count" ] < 3 :
5406+ raise HyperbrowserError (
5407+ "oversized status metadata" ,
5408+ status_code = b"4000000000000" , # type: ignore[arg-type]
5409+ )
5410+ return {"ok" : True }
5411+
5412+ result = await wait_for_job_result_async (
5413+ operation_name = "async wait helper fetch oversized numeric-bytes retries" ,
5414+ get_status = lambda : asyncio .sleep (0 , result = "completed" ),
5415+ is_terminal_status = lambda value : value == "completed" ,
5416+ fetch_result = fetch_result ,
5417+ poll_interval_seconds = 0.0001 ,
5418+ max_wait_seconds = 1.0 ,
5419+ max_status_failures = 5 ,
5420+ fetch_max_attempts = 5 ,
5421+ fetch_retry_delay_seconds = 0.0001 ,
5422+ )
5423+
5424+ assert result == {"ok" : True }
5425+ assert fetch_attempts ["count" ] == 3
5426+
5427+ asyncio .run (run ())
5428+
5429+
53005430def test_wait_for_job_result_async_retries_request_timeout_fetch_errors ():
53015431 async def run () -> None :
53025432 fetch_attempts = {"count" : 0 }
0 commit comments