@@ -828,13 +828,14 @@ async def fail_crawl(
828
828
status : CrawlStatus ,
829
829
pods : dict ,
830
830
stats : Optional [CrawlStats ] = None ,
831
+ fail_reason : Optional [str ] = "" ,
831
832
) -> bool :
832
833
"""Mark crawl as failed, log crawl state and print crawl logs, if possible"""
833
834
prev_state = status .state
834
835
835
836
failed_state : Literal ["failed" , "failed_not_logged_in" ] = "failed"
836
837
837
- if status . failReason and status . failReason == "not_logged_in" :
838
+ if fail_reason == "not_logged_in" :
838
839
failed_state = "failed_not_logged_in"
839
840
840
841
if not await self .mark_finished (crawl , status , failed_state , stats = stats ):
@@ -1496,8 +1497,6 @@ async def update_crawl_state(
1496
1497
status .size = stats .size
1497
1498
status .sizeHuman = humanize .naturalsize (status .size )
1498
1499
1499
- status .failReason = await redis .get (f"{ crawl .id } :failReason" )
1500
-
1501
1500
await self .crawl_ops .update_running_crawl_stats (
1502
1501
crawl .db_crawl_id , crawl .is_qa , stats
1503
1502
)
@@ -1612,7 +1611,9 @@ async def update_crawl_state(
1612
1611
if status .stopping and not status .pagesDone :
1613
1612
await self .mark_finished (crawl , status , "canceled" , stats )
1614
1613
else :
1615
- await self .fail_crawl (crawl , status , pods , stats )
1614
+ fail_reason = await redis .get (f"{ crawl .id } :failReason" )
1615
+
1616
+ await self .fail_crawl (crawl , status , pods , stats , fail_reason )
1616
1617
1617
1618
# check for other statuses, default to "running"
1618
1619
else :
0 commit comments