发错了!
云开发中,出现504002错误,该怎么解决?基础库 2.22.0 刚开始运行可以,后来不知道为什么,就提示错误了,请大神指点一下。云函数代码如下: 错误代码在下面。 // 云函数入口文件 const cloud = require('wx-server-sdk') cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) const db = cloud.database({ throwOnNotFound: false, }) const _ = db.command const $ = _.aggregate // 云函数入口函数 exports.main = async (event) => { /** * 先读取车轮战数据库中,对应game_id的记录 * 再比对/时间、状态、参加与否 * 然后在找到的记录中,提取一个,写入mh_id,改变状态, */ try { const transaction = await db.startTransaction() //启动事务 const aaaRes = await transaction.collection('mh_game_chelunzhan') .aggregate() //聚合数据 的方式进行筛选 .match({ zhuangtai: event.zhuangtai, //1-房间等待,2-战斗中,3-自由匹配,4-退出 game_id: event.game_id, //查找本游戏的ID mhID_1: _.neq(event.mhID), //在mhID_1和mhID_2里,没有自己mhIDr值的 mhID_2: _.neq(event.mhID) }) .sample({ //聚合中随机选了N条记录 size: 1 }) .end() const cccRes = await aaaRes.list[0]._id //将ID赋值给cccRes let dddRes = '' //设置dddRes常量 const bbbRes = await transaction.collection('mh_game_chelunzhan') // const bbbRes = await db.collection('mh_game_chelunzhan') //更新记录 .doc(cccRes) .update({ data: { zhuangtai: 2, //1-房间等待,2-战斗中,3-自由匹配,4-退出 mhID_2: event.mhID } }) .then({ dddRes = cccRes }) return { // this1: aaaRes, // this2: bbbRes, this3: dddRes // aaa:'123' } } catch (e) { console.error('transaction error', e) return { success: false, error: e } } } 错误提示如下: WASubContext.js?t=wechat&s=1644366092828&v=2.22.0:2 Unhandled promise rejection Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: Runtime.UserCodeSyntaxError: SyntaxError: Invalid shorthand property initializer at Object.module.exports.load (:16998/var/runtime/node12/UserFunction.js:32) at Runtime.handleOnce (:16998/var/runtime/node12/Runtime.engine.js:99) at Timeout._onTimeout (:16998/var/runtime/node12/Runtime.engine.js:56) at listOnTimeout (:16998/appservice/internal/timers.js:549) at processTimers (:16998/appservice/internal/timers.js:492) (callId: 1644371825870-0.3668426811601977) (trace: 9:57:5 start->9:57:6 system error (Error: errCode: -504002 functions execute fail | errMsg: Runtime.UserCodeSyntaxError: SyntaxError: Invalid shorthand property initializer at Object.module.exports.load (:16998/var/runtime/node12/UserFunction.js:32) at Runtime.handleOnce (:16998/var/runtime/node12/Runtime.engine.js:99) at Timeout._onTimeout (:16998/var/runtime/node12/Runtime.engine.js:56) at listOnTimeout (:16998/appservice/internal/timers.js:549) at processTimers (:16998/appservice/internal/timers.js:492)), abort) at C (WASubContext.js?t=wechat&s=1644366092828&v=2.22.0:2) at WASubContext.js?t=wechat&s=1644366092828&v=2.22.0:2 at WASubContext.js?t=wechat&s=1644366092828&v=2.22.0:2 at n (WASubContext.js?t=wechat&s=1644366092828&v=2.22.0:2)(env: Windows,mp,1.05.2201240; lib: 2.22.0)
2022-07-02也是前后端分离,用多种方法始终搞不定这个
授权入口页所在域名:空?response.sendRedirect(url);看了好多地方不知道这个是什么原因一直显示这个问题
2021-10-25