以下代码用实时数据推送,在微信开发者工具及手机端都能正常稳定运行。
但在Win10的环境下,当isClosedLoop = true正常运行,但当isClosedLoop = false则报错。
经过无数次调测,最后将布尔值true、false改为数字1、0,问题解决。
结论,这应该是一个bug:windows下实时数据推送,传参为布尔值false就会报错。
windows版本:win10专业版1903
微信版本:2.9.5.41
代码:
let isClosedLoop
if (that.data.currentTabs == 'processing') {
isClosedLoop = false
} else {
isClosedLoop = true
}
const db = wx.cloud.database()
const _ = db.command
console.log('[需求列表] : 开始监听')
const watcher = db.collection('support').orderBy('createTime', 'desc').limit(that.data.supportListLimit)
.where(_.and({
closedLoop: isClosedLoop
}, _.or({
frontlineOpenId: that.data.loginInfo.staffOpenId
}, {
supportOpenId: that.data.loginInfo.staffOpenId
})))
.watch({
onChange: function (snapshot) {
console.log(snapshot)
},
onError: function (err) {
console.error('the watch closed because of error', err)
}
})
在Windows的环境下,当isClosedLoop = false报错:
thirdScriptError
[realtime] onMessage parse res.data error: SyntaxError: Unexpected token o in JSON at position 1;at socketTask.onmessage callback function
Error: [realtime] onMessage parse res.data error: SyntaxError: Unexpected token o in JSON at position 1
at n.Bi.onSocketMessage (file://6.js/:2:508995)
at n.e (file://6.js/:2:260063)
at i. (file://6.js/:2:128008)
at i.emit (file://6.js/:2:615034)
at file://6.js/:2:1311903
at file://6.js/:2:607765
at Object.m (file://6.js/:2:77725)
at file://199.js/:1:57
问题已复现,我们会在后续版本中进行修复。