下面是运行结果,有时候两个都成功,有时候两个都失败,有时候一个成功一个失败
23:55:19.489 [本地调试]res---- {"id":"64f9f267f08210d515290329"}
23:55:19.504 [本地调试]err--------- uniCloud-aliyun/cloudfunctions/hallctrl/controller/hall.js:700:12
23:55:19.504 [本地调试]Error: invalid transactionId ac1cd383-21ea8e4d-7523-40ce-bb41-7ba2578bf9d4
23:55:19.504 [本地调试] at processTicksAndRejections (node:internal/process/task_queues:96:5)
- 发布:2023-09-08 00:24
- 更新:2023-09-08 10:52
- 阅读:320
产品分类: uniCloud/App
操作步骤:
预期结果:
23:55:19.489 [本地调试]res----
23:55:19.489 [本地调试]res----
23:55:19.489 [本地调试]res----
23:55:19.489 [本地调试]res----
实际结果:
下面是运行结果,有时候两个都成功,有时候两个都失败,有时候一个成功一个失败
23:55:19.489 [本地调试]res---- {"id":"64f9f267f08210d515290329"}
23:55:19.504 [本地调试]err--------- uniCloud-aliyun/cloudfunctions/hallctrl/controller/hall.js:700:12
23:55:19.504 [本地调试]Error: invalid transactionId ac1cd383-21ea8e4d-7523-40ce-bb41-7ba2578bf9d4
23:55:19.504 [本地调试] at processTicksAndRejections (node:internal/process/task_queues:96:5)
下面是运行结果,有时候两个都成功,有时候两个都失败,有时候一个成功一个失败
23:55:19.489 [本地调试]res---- {"id":"64f9f267f08210d515290329"}
23:55:19.504 [本地调试]err--------- uniCloud-aliyun/cloudfunctions/hallctrl/controller/hall.js:700:12
23:55:19.504 [本地调试]Error: invalid transactionId ac1cd383-21ea8e4d-7523-40ce-bb41-7ba2578bf9d4
23:55:19.504 [本地调试] at processTicksAndRejections (node:internal/process/task_queues:96:5)
bug描述:
const transaction = await db.startTransaction()
try{
let userUpdate = {}
userUpdate['fen'] = user.fen-amount
userUpdate['lastonlinetime'] = Math.floor(Date.now()/1000)
userUpdate['leijitixian'] = user.leijitixian+amount
userUpdate['ip'] = this.ctx.context.CLIENTIP
const updateUserRes = transaction.collection('userinfo').doc(user._id).update(userUpdate)
const withdrawrecordLogRes = transaction.collection('withdrawrecord_log').add({uid:user._id,
out_batch_no:'out_batch_no',
count:amount,
balance:user.fen,
shangji,
shangjiIsAgency,
tixianType:0,
createtime:Math.floor(Date.now()/1000)})
updateUserRes.then((res)=>{
console.log('res----',res);
}).catch((err)=>{
console.log('err---------',err);
})
withdrawrecordLogRes.then((res)=>{
console.log('res----',res);
}).catch((err)=>{
console.log('err---------',err);
})
await transaction.commit()
}catch(e){
await transaction.rollback()
console.error(`transaction error`, e)
return {'errcode': 10001}
}
下面是运行结果,有时候两个都成功,有时候两个都失败,有时候一个成功一个失败
23:55:19.489 [本地调试]res---- {"id":"64f9f267f08210d515290329"}
23:55:19.504 [本地调试]err--------- uniCloud-aliyun/cloudfunctions/hallctrl/controller/hall.js:700:12
23:55:19.504 [本地调试]Error: invalid transactionId ac1cd383-21ea8e4d-7523-40ce-bb41-7ba2578bf9d4
23:55:19.504 [本地调试] at processTicksAndRejections (node:internal/process/task_queues:96:5)
1 个回复
DCloud_uniCloud_VK
你没加await,在云函数里不可以用then