云函数调用startTransaction()引用数据库事务,安装"wx-server-sdk": "^1.7.0,云函数本地调试可以成功调用。
但上传并部署(所有文件)调用则报错,请问什么原因?
{"errorCode":1,"errorMessage":"user code exception caught","stackTrace":"transaction is not defined\nReferenceError: transaction is not defined\n at EventHandler.exports.main [as realHandler] (/var/user/index.js:92:5)\n at \u003canonymous\u003e\n at process._tickCallback (internal/process/next_tick.js:188:7)"}
"[ResourceUnavailable.TransactionNotE"[ResourceUnavailable.TransactionNotExist] Transaction does not exist on the server, transaction must be commit or abort in 30 seconds. Please check your request, but if the problem persists, contact us."xist] Transaction does not exist on the server, transaction must be commit or abort in 30 seconds. Please check your request, but if the problem persists, contact us."
在db里加入throwOnNotFound: false get没有数据时,就不会报错。
我的也报了,但是在另外一个纯云函数里没有。报错的这个云函数是里面包含了很多请求,根据参数来switch到不同的方法里,你的也是这样写的吗?云函数自身的返回结果log和你的一样,但是我catch到的错误如下
{ code: 'SIGN_PARAM_INVALID',
message: 'envname field not exsit in url' }
ReferenceError: transaction is not defined
“transaction is not defined”这个错误是官方demo有问题,const transaction = await db.startTransaction() 放在try的里面,catch里面肯定找不到
这就开始用了。哥们你是先驱啊,应该你来帮别人答疑的。