为什么云开发用着用着突然查询方法就报错了?一点提醒都没有?

发布于 5 年前作者 fang627381 次浏览最后编辑 5 年前来自 ask

下面所有代码,在本地可以正常运行,上传之后就各种报错! 让我怎么调试啊。???

 const lookup = {

        from: 'flowersRecord',

        as: 'flowersRecord',

        let: {

            readUserId: '$openId'

        },

        pipeline: $.pipeline()

            // .match( // 为什么一使用这个就报错, 之前是可以的!!!

            //     _.expr($.and([

            //         $.eq(['$openId', '$$readUserId']),

            //         $.eq(['$type', 3])

            //     ]))

            // )

            .group({ _id: null, countTime: $.sum('$getFlowersTime') }).done()

    }


之前是可以稳定运行的,过了一段时间打开小程序,发现不能运行了, 是不是版本更新就不让用了,也不通知一下.

这句话,开启本地调试就没有问题! 发布线上就不行!!

// .match( // 为什么一使用这个就报错, 之前是可以的!!!

            //     _.expr($.and([

            //         $.eq(['$openId', '$$readUserId']),

            //         $.eq(['$type', 3])

            //     ]))

            // )


还有这个也是一样, 本地可以,线上不行! 然后之前发布也能用,现在突然报错了!!!

const where = {}  

const recommendList = await users

        .aggregate()

        .lookup(lookup)

        .replaceRoot({ newRoot: $.mergeObjects([$.arrayElemAt(['$flowersRecord', 0]), '$$ROOT']) })

        .lookup(lookupAppCount)

        .replaceRoot({ newRoot: $.mergeObjects([$.arrayElemAt(['$appCount', 0]), '$$ROOT']) })

        .project(project)

        // .match(where) // 如果 where 为空对象 {} 就会报错, 神经把, 要不之前就报错,现在突然报错。

        .limit(20)

        .sort({

            len: -1

        })

        .end();



错误代码:

Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID 7825b4ce-705c-11ec-abeb-52540048fc82, cloud function service error code -504002, error message Error: collection.aggregate:fail -501001 resource system error. [FailedOperation.Timeout] Execution request timeout, Please check optimize your request(such as index), but if the problem persists, contact us.↵ at Object.toSDKError (/var/user/node_modules/wx-server-sdk/index.js:8064:19)



2 回复
leikang
leikang1 楼4 年前

看到timeout字样。

minsong
minsong2 楼5 个月前

数据多了才报错的吧 没索引