收藏
回答

云函数使用geoNear报错,说geopoint的值必须是number?

今天遇到一个非常奇怪找不到原因的bug

在云函数中写了一个geoNear聚合函数,返回不到数据,空值,也没有报错,反复找bug找了三个小时,发现应该是genNear参数里面要的geopoint识别有bug,又反复检查了n遍都找不到问题在哪,云函数也找不到问题,因为我每个函数都用的同一个point数据,是个全局变量,在以前写的别的函数就都能用,就今晚新写的云函数不行,最后我没办法了,为了找到问题,我复制了一个前一阵写的一模一样的云函数,上传到云端,用同样的参数调用,结果是今天以前上传的云函数都可以用,只有今天上传的云函数使用同一个geoPoint就报错?这样就不是代码问题了,是版本或者服务器问题吧?

所以折腾了我整整一晚上还是找不到原因,谁能救救我?

VM5689 WAService.js:2 Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: Error: Geo Point must be number type
    at Function.isGeopoint (:48047/var/user/node_modules/@cloudbase/database/dist/commonjs/validate.js:13)
    at new Point (:48047/var/user/node_modules/@cloudbase/database/dist/commonjs/geo/point.js:8)
    at Aggregation.geoNear (:48047/var/user/node_modules/@cloudbase/database/dist/commonjs/aggregate.js:86)
    at Aggregate.pushStage (:48047/var/user/node_modules/wx-server-sdk/index.js:1088)
    at Aggregate.geoNear (:48047/var/user/node_modules/wx-server-sdk/index.js:1109)
    at Runtime.exports.main [as handler] (:48047/var/user/index.js:29)
    at Runtime.handleOnce (:48047/var/runtime/node12/Runtime.engine.js:219)
    at Timeout._onTimeout (:48047/var/runtime/node12/Runtime.engine.js:56)
    at listOnTimeout (:48047/appservice/internal/timers.js:549)
    at processTimers (:48047/appservice/internal/timers.js:492) (callId: 1657354987492-0.30759337613434545) (trace: 16:23:7 start->16:23:8 system error (Error: errCode: -504002 functions execute fail | errMsg: Error: Geo Point must be number type
    at Function.isGeopoint (:48047/var/user/node_modules/@cloudbase/database/dist/commonjs/validate.js:13)
    at new Point (:48047/var/user/node_modules/@cloudbase/database/dist/commonjs/geo/point.js:8)
    at Aggregation.geoNear (:48047/var/user/node_modules/@cloudbase/database/dist/commonjs/aggregate.js:86)
    at Aggregate.pushStage (:48047/var/user/node_modules/wx-server-sdk/index.js:1088)
    at Aggregate.geoNear (:48047/var/user/node_modules/wx-server-sdk/index.js:1109)
    at Runtime.exports.main [as handler] (:48047/var/user/index.js:29)
    at Runtime.handleOnce (:48047/var/runtime/node12/Runtime.engine.js:219)
    at Timeout._onTimeout (:48047/var/runtime/node12/Runtime.engine.js:56)
    at listOnTimeout (:48047/appservice/internal/timers.js:549)
    at processTimers (:48047/appservice/internal/timers.js:492)), abort)
    at C (VM5689 WAService.js:2)
    at VM5689 WAService.js:2(env: macOS,mp,1.06.2206271; lib: 2.24.3)

以上是报错的代码,有没有人能看得懂咋回事啊。。。

最后一次编辑于  2022-07-09
回答关注问题邀请回答
收藏

1 个回答

  • a互联未来
    a互联未来
    2022-10-18
    "location":{"type":"Point","coordinates":[parseFloat(longitude),parseFloat(latitude)]}
    


    2022-10-18
    有用
    回复
登录 后发表内容