我希望调用我的云函数接口后,立即返回,并且异步去做耗时操作。现在是接口有返回,但是云函数会判断超时,我的耗时操作并没有完成
router.post('/updateItem', async function (ctx, next) {
const { ENV, OPENID, APPID } = cloud.getWXContext()
const {
collection, _id, itemid
} = JSON.parse(ctx.req.body.toString('utf-8'))
const db = cloud.database()
let { data: orderList } = await db
.collection('order')
.doc(_id).get();
if (orderList) {
let item = { ...orderList.items[itemid] }
item.collection = collection
orderList.items.splice(item.id, 1, item)
await db
.collection('order')
.doc(_id).update({
data: {
items: orderList.items
}
})
// 耗时操作
generateZip(orderList, item)
ctx.body = {
code: 0,
data: ""
}
}
else {
ctx.body = {
code: -1,
msg: "找不到订单"
}
}
})
async function generateZip(order, boughtItem) {
}
日志报错
ERROR RequestId:caf47d0e-2a00-11eb-9171-5254002665ac Result:{"errorCode":-1,"errorMessage":"Async invoking task timed out after 5 seconds"}
END RequestId: caf47d0e-2a00-11eb-9171-5254002665ac
Report RequestId: caf47d0e-2a00-11eb-9171-5254002665ac Duration:5000ms Memory:256MB MemUsage:72.132812MB