一样的问题,求官方解答 // 客户端 if (e.detail.errMsg === 'getPhoneNumber:ok') { // 用户同意授权,且 e.detail 中会包含 cloudID const { cloudID, code, encryptedData, iv } = e.detail wx.cloud.callFunction({ name: 'getPhoneNumber', // 云函数名称 data: { cloudID: cloudID }, success: (res) => { console.log('云函数返回:', res.result) const { phoneNumber, purePhoneNumber, countryCode } = res.result wx.showToast({ title: `手机号:${phoneNumber}`, icon: 'success', }) // 你可以将手机号保存到数据库或做其他处理 }, fail: (err) => { console.error('调用云函数失败:', err) wx.showToast({ title: '获取手机号失败', icon: 'none', }) }, }) // 云函数 const result = await cloud.getOpenData({ list: [{ cloudID: event.cloudID }], // 传入 cloudID }) // 报错信息 getOpenData:fail The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Object
小程序云函数报错?最近几天屡次出现云函数报错,什么原因? [图片][图片] 报错日志: action: functions.InvokeFunction clientIp: 2409:8924:5a4c:96:c1e0:8670:acf1:8c2f code: FUNCTIONS_EXECUTE_FAIL envId: user-phone-2gvztrx8bf093969 errInfo: map[code:UnknownError message:TypeErrgetOpenData:fail or [ERR_INVALID_ARG_TYPE]: getOpenData:fail The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type undefined] message: TypeErrgetOpenData:fail or [ERR_INVALID_ARG_TYPE]: getOpenData:fail The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type undefined at Function.byteLength (buffer.js:515:11) at BufferWriter.write_string_buffer [as string] (/var/user/node_modules/protobufjs/src/writer_buffer.js:68:22) at Function.encode (/var/user/node_modules/wx-server-sdk/index.js:5465:58) at Promise (/var/user/node_modules/wx-server-sdk/index.js:2037:83) at new Promise (<anonymous>) at Cloud.getOpenData (/var/user/node_modules/wx-server-sdk/index.js:2022:16) at Object.args [as getOpenData] (/var/user/node_modules/wx-server-sdk/index.js:123:29) at exports.main (/var/user/index.js:11:22) at IncomingMessage.TestHTTPHandle.req.on (/data/scf/frame/runtime.js:224:26) at IncomingMessage.emit (events.js:194:15) resourceName: getPhone sdkVersion: wx-miniprogram-sdk/3.4.8 (NaN platform/ios}) seqId: 1719728033959_0.27450381858912454_16797995 tags: [logFrom=middleware] timestamp: 1.719728034114e+12 action: functions.InvokeFunction clientIp: 2409:8924:5a4c:96:c1e0:8670:acf1:8c2f code: FUNCTIONS_EXECUTE_FAIL envId: user-phone-2gvztrx8bf093969 errInfo: map[code:UnknownError message:TypeErrgetOpenData:fail or [ERR_INVALID_ARG_TYPE]: getOpenData:fail The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type undefined] message: TypeErrgetOpenData:fail or [ERR_INVALID_ARG_TYPE]: getOpenData:fail The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type undefined at Function.byteLength (buffer.js:515:11) at BufferWriter.write_string_buffer [as string] (/var/user/node_modules/protobufjs/src/writer_buffer.js:68:22) at Function.encode (/var/user/node_modules/wx-server-sdk/index.js:5465:58) at Promise (/var/user/node_modules/wx-server-sdk/index.js:2037:83) at new Promise (<anonymous>) at Cloud.getOpenData (/var/user/node_modules/wx-server-sdk/index.js:2022:16) at Object.args [as getOpenData] (/var/user/node_modules/wx-server-sdk/index.js:123:29) at exports.main (/var/user/index.js:11:22) at IncomingMessage.TestHTTPHandle.req.on (/data/scf/frame/runtime.js:224:26) at IncomingMessage.emit (events.js:194:15) resourceName: getPhone sdkVersion: wx-miniprogram-sdk/3.4.8 (NaN platform/ios}) seqId: 1719728029376_0.5032832276993913_16779577 tags: [logFrom=afterFuncCb] timestamp: 1.719728030786e+12 action: functions.InvokeFunction clientIp: 2409:8924:5a4c:96:c1e0:8670:acf1:8c2f code: FUNCTIONS_EXECUTE_FAIL envId: user-phone-2gvztrx8bf093969 errInfo: map[code:UnknownError message:TypeErrgetOpenData:fail or [ERR_INVALID_ARG_TYPE]: getOpenData:fail The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type undefined] message: TypeErrgetOpenData:fail or [ERR_INVALID_ARG_TYPE]: getOpenData:fail The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type undefined at Function.byteLength (buffer.js:515:11) at BufferWriter.write_string_buffer [as string] (/var/user/node_modules/protobufjs/src/writer_buffer.js:68:22) at Function.encode (/var/user/node_modules/wx-server-sdk/index.js:5465:58) at Promise (/var/user/node_modules/wx-server-sdk/index.js:2037:83) at new Promise (<anonymous>) at Cloud.getOpenData (/var/user/node_modules/wx-server-sdk/index.js:2022:16) at Object.args [as getOpenData] (/var/user/node_modules/wx-server-sdk/index.js:123:29) at exports.main (/var/user/index.js:11:22) at IncomingMessage.TestHTTPHandle.req.on (/data/scf/frame/runtime.js:224:26) at IncomingMessage.emit (events.js:194:15) resourceName: getPhone sdkVersion: wx-miniprogram-sdk/3.4.8 (NaN platform/ios}) seqId: 1719728032623_0.6815750717068587_16792354 tags: [logFrom=middleware] timestamp: 1.71972803275e+12
2天前我也一样的,支付都可以,就是分享到朋友和朋友圈不可以,为什么呢?
updateAppMessageShareData无法正常调用分享在调试模式下,config反馈ok,使用低版本支持的onMenuShareAppMessage和onMenuShareTimeline也都正常工作,但换成官方建议的updateAppMessageShareData和updateTimelineShareData, 在开发者工具上会报错:updateTimelineShareData:fail, the permission value is offline verifying 在安卓微信 7.0.10 版本会报错:updateTimelineShareData:permission denied 其中,config里有配置需要用到的jsApiList 其次,在ready里调用checkJsApi,且checkJsApi里也写了新旧两种的jsApiList,手机上debug,显示新旧两种jsApiList都可用,再在success里调用的updateTimelineShareData,结果说permission denied 复现链接: https://test-www.sanguozhan888.com/share/wechat/?uid=10013 [图片] [图片] [图片] [图片] [图片] wx.config({ debug: true, appId: config_info.appId, timestamp: config_info.timestamp, nonceStr: config_info.nonceStr, signature: config_info.signature, jsApiList: [ 'checkJsApi', 'onMenuShareAppMessage', 'onMenuShareTimeline', 'updateAppMessageShareData', 'updateTimelineShareData' ] }); wx.ready(function () { wx.checkJsApi({ jsApiList: [ 'onMenuShareAppMessage', 'onMenuShareTimeline', 'updateAppMessageShareData', 'updateTimelineShareData' ], // 需要检测的JS接口列表,所有JS接口列表见附录2, success: function(res) { console.log('checkJsApi:', res) if (res.checkResult.updateAppMessageShareData || res.checkResult.onMenuShareAppMessage) { wx.updateAppMessageShareData({ title: 'XXX', // 分享标题 desc: 'XXXXXX', // 分享描述 link: 'https://test-www.sanguozhan888.com/share/wechat/?uid=10013', // 分享链接 imgUrl: 'https://test-www.sanguozhan888.com/share/imgs/share300.png', // 分享图标 success: function (data) { // 设置成功 console.log('updateAppMessageShareData success:', data); }, fail: function(error) { console.log('updateAppMessageShareData error:', error); } }); } if (res.checkResult.updateTimelineShareData || res.checkResult.onMenuShareTimeline) { wx.updateTimelineShareData({ title: 'XXX', // 分享标题 link: 'https://test-www.sanguozhan888.com/share/wechat/?uid=10013', // 分享链接 imgUrl: 'https://test-www.sanguozhan888.com/share/imgs/share300.png', // 分享图标 success: function (data) { // 设置成功 console.log('updateTimelineShareData success:', data); }, fail: function(error) { console.log('updateTimelineShareData error:', error); } }); } } }); }); 希望官方可以帮忙查看一下,翻看过社区里的帖子,能试的都试过了,都无法工作(官方有说法旧的要快废弃了,但新的又无法工作怎么办)
2020-10-31