0

我从 algolia 获取每页 200 条记录并将数据发布到 courier 但在处理 4 或 5 页不一致后,它给出了此错误:函数执行耗时 60004 毫秒,状态为“超时”

    async scheduleCourierProjectVendors() {
            this.allProjects = await this._projectMetricsController.getAllProjects();
            console.info('Total projects: ', this.allProjects.length);
            for (const project of this.allProjects) {
                await this.manageProjectVendors(project, false);
            }
        }
    
    async manageProjectVendors(newData, isClaimStatus) {
            if (newData) {
                try {
                    const claimVendorText = isClaimStatus ? 'claimed' : 'unclaimed';
                    newData['page'] = newData['page'] || config.data.zero;
                    const vendorResult = await this._algoliyaController.getVendors(newData, isClaimStatus); //Fetch 200 records per page
                    const vendorsData = vendorResult['hits'] || [];
                    console.info(`Total matched ${claimVendorText} vendors for this project: ${newData.customId} `, vendorsData.length);
                    if (vendorsData.length) {
                        let listId; let listName;
                        if (isClaimStatus) {
                            listId = `project.${newData.customId}.claimed.vendors`;
                            listName = `${newData.title} Claimed Vendors`;
                        } else {
                            listId = `project.${newData.customId}.unclaimed.vendors`;
                            listName = `${newData.title} Unclaimed Vendors`;
                        }
                        await this._courierNotificationListController.createList(listId, listName);
                        let vCount = config.data.one;
                        for (const vdata of vendorsData) {
                            console.info(`${claimVendorText} vendor processing for this project: ${newData.customId} and count: `, vCount);
                            await this._courierNotificationProfileController.createRecipient(listId, vdata.uid, vdata.id);
                            vCount++;
                        }
                    } else {
                        console.info(`No ${claimVendorText} vendor matches for this project: `, newData.customId);
                    }
    
    
                    if (newData['page'] < vendorResult['nbPages'] - config.data.one) {
                        setTimeout(async () => {
                            newData['page'] += config.data.one;
                            console.info(`Attempting more ${claimVendorText} vendor for this project: ${newData.customId} and page#: ${newData['page']}`);
                            await this.manageProjectVendors(newData, isClaimStatus);
                        }, config.data.delay10Seconds);
                    }
                } catch (err) {
                    console.info(`Error`, JSON.stringify(err));
                }
            }
        }
4

0 回答 0