问题已解决
- 发布:2021-06-23 22:07
- 更新:2021-06-25 14:18
- 阅读:475
问题已解决
吴克 (作者)
async function forLoops(i) {
if(i<1670000)
{
try{
const res = await uniCloud.httpclient.request(`xxxxxxxxxxxxxxxxxxxxxxxx`,{
dataType:'json'
})
if(res){
// uniCloud.logger.log(res.data)
if(res.data.status === "ok"){
// await collection.add(res.data.result)
await collection.doc(res.data.result.appid).set(res.data.result)
await collection.doc('lastappid').set({
appid:res.data.result.appid
})
}
// upsert(res.data.result)
}
}catch(e){
console.error(e.status)
}
setTimeout(()=>{
// forLoops(i+=1)
process.nextTick(forLoops, i+=1);
}, 1000)
}
}
exports.main = async (event) => {
let lastappid = await collection.doc('lastappid').get()
lastappid=lastappid.data[0]['appid']
uniCloud.logger.log(lastappid)
await forLoops(lastappid)
}
吴克 (作者)
的确啊,函数运行个几秒就报执行结果undefind,那么爬虫类的云函数还能跑吗?
14:10:56.335 [本地运行:阿里云:xiaohh]本地运行云函数【xxx】...
14:10:56.335 [本地运行:阿里云:xiaohh]运行日志:
14:10:57.707 [本地运行]440 C:/Users/hugetiny/Documents/HBuilderProjects/爬/uniCloud-aliyun/cloudfunctions/xxx/index.js:63:17
14:10:57.876 [本地运行]403 C:/Users/hugetiny/Documents/HBuilderProjects/爬/uniCloud-aliyun/cloudfunctions/xxx/index.js:46:10
14:10:57.893 [本地运行]"云函数[xxx]执行结果:" undefined
14:10:59.003 [本地运行]403 C:/Users/hugetiny/Documents/HBuilderProjects/爬/uniCloud-aliyun/cloudfunctions/xxx/index.js:46:10
14:11:00.136 [本地运行]403 C:/Users/hugetiny/Documents/HBuilderProjects/爬/uniCloud-aliyun/cloudfunctions/xxx/index.js:46:10
14:11:01.272 [本地运行]403 C:/Users/hugetiny/Documents/HBuilderProjects/爬/uniCloud-aliyun/cloudfunctions/xxx/index.js:46:10
14:11:02.419 [本地运行]403 C:/Users/hugetiny/Documents/HBuilderProjects/爬/uniCloud-aliyun/cloudfunctions/xxx/index.js:46:10
14:11:03.550 [本地运行]403 C:/Users/hugetiny/Documents/HBuilderProjects/爬/uniCloud-aliyun/cloudfunctions/xxx/index.js:46:10
14:11:04.671 [本地运行]403 C:/Users/hugetiny/Documents/HBuilderProjects/爬/uniCloud-aliyun/cloudfunctions/xxx/index.js:46:10
14:11:05.801 [本地运行]403 C:/Users/hugetiny/Documents/HBuilderProjects/爬/uniCloud-aliyun/cloudfunctions/xxx/index.js:46:10
14:11:06.946 [本地运行]403 C:/Users/hugetiny/Documents/HBuilderProjects/爬/uniCloud-aliyun/cloudfunctions/xxx/index.js:46:10
14:11:07.001 [本地运行:阿里云:xxxxxx]云函数本地运行超时。 【调整超时时间】
DCloud_uniCloud_WYQ
回复 吴克: 没有return 就是 return undefined,你把代码贴出来吧
2021-06-25 11:22