OnScheduleHandler not completing scheduled code

I am facing an issue with my onScheduledEvent handler not completing the entirety of my code I have written. I am trying to cache a pull of a product catalog that I get from Dell after extracting the data I care about. I can confirm that this pull is successful for both end points and is not too big to be saved using the data method and will complete if it is just CA or US, but not both. It does take a little longer than usual to receive a response from the endpoints call, but I am using async methods. This was also tested before rolled out and confirmed to be working as expected. This is causing downtime for my customer. I need help resolving this issue. Please find my code below:

 onScheduledEventHandler: async function(args) {
    var key, options, orderDataCA, orderDataUS;
    console.log("Logging arguments from onScheduledEventHandler: " + JSON.stringify(args))

    var tokeca= await getToken(caform); 
    catoken = tokeca['access_token']
    var tokeus = await getToken(usform);
    ustoken = tokeus['access_token']

    // await sleep(2000);
    var cacatalog = await getCatalogCA(catoken);
    console.log(`Canada catalog length is ${cacatalog.length} items long.`);

    tempOptions = buildOptions(cacatalog)    
    var options = [] 
    for (var item of tempOptions){
      options[item['manu_id']] =item
    }
    key = "CA-Catalog-s";
    console.log("Deleting old databased CA catalog...")
    await deleteDB(key)
    console.log("Setting new databased CA catalog...")
    await setDB(key, options[undefined]);
   
    var uscatalog = await getCatalogUS(ustoken);
    console.log(`US catalog length is ${uscatalog.length} items long.`);

    tempOptions = buildOptions(uscatalog)  
    var options = [] 
    for (var item of tempOptions){
      options[item['manu_id']] =item
    }  
    key = "US-Catalog-s";
    console.log("Deleting old databased US catalog...")
    await deleteDB(key)
    console.log("Setting new databased US catalog...")
    await setDB(key, options[undefined]);

    var allStatusesUS = await getDB("ordersWithStatusUSsand");
    var allStatusesCA = await getDB("ordersWithStatusCAsand");

    orderDataUS = await getDB("ordersUSsand");
    orderDataCA = await getDB("ordersCAsand");

    console.log("US orders: ", orderDataUS['poNums'])
    console.log("CA orders: ", orderDataCA['poNums'])
    
    var orderhash = {}
}

Pretty sure the severless functions timeout after 20 seconds when they are running in product. You don’t have this limitation when running your code locally. So your problem might be caused by a timeout.

Exactly the same popped into my head when reading through your issue.

I fell over this problem when developing a HEICtoJPG converter (so convert and upload JPGs in order to view them in FD directly).
Everything fine when testing, but ran into the timeout when in prod.

In my experience you can also not compare runtimes as serverless environment seems to be less performant than local testing.

So you need to make sure that your function is way ahead of these 20 seconds when testing.