收藏
回答

subscribeMessage.send errCode: -504002报错?

Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: TypeError: Do not know how to serialize a BigInt

调用订阅消息后测试消息可以发送成功,但是返回值报错Do not know how to serialize a BigInt,无法判断是否发送成功。


2022-05-01 解决方法:云函数的返回值不要返回result,直接返回result.errCode,就不会报错。原因是直接返回result被序列化导致报错(其实就是bug),所以返回result.errCode足以用于判断!

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

13 个回答

  • .
    .
    发表于小程序端
    2022-05-01

    解决方法:云函数的返回值不要返回result,直接返回result.errCode,就不会报错。

    2022-05-01
    有用 11
    回复 1
    • lm
      lm
      01-17
      这个问题 直接返回result.errCode 也会出错,我的这边表现为有时返回的结果有问题,有时正常
      01-17
      回复
  • 点横撇捺
    点横撇捺
    2022-04-13

    这个问题我当时遇到的情况是完成发送订阅消息后return(result),就会报出这个错误,后来我注释掉return(result)就不报错了,不知道什么原因。

    2022-04-13
    有用 1
    回复
  • 今晚要熬夜
    今晚要熬夜
    05-10

    这种如何解决呢?

    Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: Runtime.ImportModuleError: Error: Cannot find module 'wx-server-sdk'

    Require stack:

    - /var/user/index.js

    - /var/runtime/node16/UserFunction.js

    - /var/runtime/node16/Runtime.engine.js

    - /var/runtime/node16/bootstrap.js

        at Object.module.exports.load (/var/runtime/node16/UserFunction.js:34:13)

        at Runtime.handleOnce (/var/runtime/node16/Runtime.engine.js:85:38)

        at Timeout._onTimeout (/var/runtime/node16/Runtime.engine.js:54:12)

        at listOnTimeout (node:internal/timers:557:17)

        at processTimers (node:internal/timers:500:7) (callId: 1715271882467-0.7034750134270631) (trace: 0:24:42 start->0:24:43 system error (Error: errCode: -504002 functions execute fail | errMsg: Runtime.ImportModuleError: Error: Cannot find module 'wx-server-sdk'

    Require stack:

    - /var/user/index.js

    - /var/runtime/node16/UserFunction.js

    - /var/runtime/node16/Runtime.engine.js

    - /var/runtime/node16/bootstrap.js

        at Object.module.exports.load (/var/runtime/node16/UserFunction.js:34:13)

        at Runtime.handleOnce (/var/runtime/node16/Runtime.engine.js:85:38)

        at Timeout._onTimeout (/var/runtime/node16/Runtime.engine.js:54:12)

        at listOnTimeout (node:internal/timers:557:17)

        at processTimers (node:internal/timers:500:7)), abort)

        at R (<anonymous>:1:245532)

        at <anonymous>:1:279958(env: Windows,mp,1.06.2402040; lib: 3.4.3)

    05-10
    有用
    回复
  • .
    .
    2022-08-22

    相同问题 +1,本地调试发现 result 里面的 msgid 竟然是个 BigInt 类型(似乎这个问题也会导致本地调试云函数一直无法 response)

    我的解决方法:将 msgid 转成 string 进行返回

    (这里是个 demo 所以没有做 msgid 是否为空判断,有需要可以自己处理)


    再补一张 toString 以后的图

    2022-08-22
    有用
    回复
  • Aacheng
    Aacheng
    2022-08-20

    感谢楼主,已被坑了一天了

    2022-08-20
    有用
    回复
  • 卓
    2022-08-04

    get openid fail Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: ReferenceError: wx is not defined

        at Object.<anonymous> (:12168/var/user/index.js:3)

        at Module._compile (:12168/appservice/internal/modules/cjs/loader.js:1158)

        at Object.Module._extensions..js (:12168/appservice/internal/modules/cjs/loader.js:1178)

        at Module.load (:12168/appservice/internal/modules/cjs/loader.js:1002)

        at Function.Module._load (:12168/appservice/internal/modules/cjs/loader.js:901)

        at Module.require (:12168/appservice/internal/modules/cjs/loader.js:1044)

        at require (:12168/appservice/internal/modules/cjs/helpers.js:77)

        at Object.module.exports.load (:12168/var/runtime/node12/UserFunction.js:26)

        at Runtime.handleOnce (:12168/var/runtime/node12/Runtime.engine.js:99)

        at Timeout._onTimeout (:12168/var/runtime/node12/Runtime.engine.js:56) (callId: 1659562043691-0.015394991480191855) (trace: 5:27:23 start->5:27:23 app show->5:27:24 system error (Error: errCode: -504002 functions execute fail | errMsg: ReferenceError: wx is not defined

        at Object.<anonymous> (:12168/var/user/index.js:3)

        at Module._compile (:12168/appservice/internal/modules/cjs/loader.js:1158)

        at Object.Module._extensions..js (:12168/appservice/internal/modules/cjs/loader.js:1178)

        at Module.load (:12168/appservice/internal/modules/cjs/loader.js:1002)

        at Function.Module._load (:12168/appservice/internal/modules/cjs/loader.js:901)

        at Module.require (:12168/appservice/internal/modules/cjs/loader.js:1044)

        at require (:12168/appservice/internal/modules/cjs/helpers.js:77)

        at Object.module.exports.load (:12168/var/runtime/node12/UserFunction.js:26)

        at Runtime.handleOnce (:12168/var/runtime/node12/Runtime.engine.js:99)

        at Timeout._onTimeout (:12168/var/runtime/node12/Runtime.engine.js:56)), abort)

        at S (WASubContext.js?t=wechat&s=1659560544268&v=2.24.1:2)

        at WASubContext.js?t=wechat&s=1659560544268&v=2.24.1:2

        at WASubContext.js?t=wechat&s=1659560544268&v=2.24.1:2

        at n (WASubContext.js?t=wechat&s=1659560544268&v=2.24.1:2)

    突然间出现这个问题,云函数不能使用了,是什么原因呢?

    2022-08-04
    有用
    回复
  • Carrot
    Carrot
    2022-04-09

    等一个解决方案

    2022-04-09
    有用
    回复
  • 青春。亦不回头
    青春。亦不回头
    2022-04-06

    我也遇到了 该怎么解决啊

    2022-04-06
    有用
    回复
  • 红萝卜炒鸡蛋
    红萝卜炒鸡蛋
    2022-04-01

    今天我也碰到了,应该是官方BUG,不知什么时候解决?

    2022-04-01
    有用
    回复
  • ien
    ien
    2022-03-26

    能成功发送,但是会报错,请问怎么解决

     Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: TypeError: Do not know how to serialize a BigInt

        at JSON.stringify (<anonymous>)

        at callback (:20269/var/runtime/node12/CallbackContext.js:31)

        at :20269/var/runtime/node12/CallbackContext.js:81

        at :20269/var/runtime/node12/Runtime.engine.js:237

        at processTicksAndRejections (:20269/appservice/internal/process/task_queues.js:97) (callId: 1648270421746-0.8908816914399289) (trace: 12:53:41 start->12:53:42 system error (Error: errCode: -504002 functions execute fail | errMsg: TypeError: Do not know how to serialize a BigInt

        at JSON.stringify (<anonymous>)

        at callback (:20269/var/runtime/node12/CallbackContext.js:31)

        at :20269/var/runtime/node12/CallbackContext.js:81

        at :20269/var/runtime/node12/Runtime.engine.js:237

        at processTicksAndRejections (:20269/appservice/internal/process/task_queues.js:97)), abort)

        at on (WASubContext.js?t=wechat&s=1648259951586&v=2.19.4:2)

        at WASubContext.js?t=wechat&s=1648259951586&v=2.19.4:2

        at WASubContext.js?t=wechat&s=1648259951586&v=2.19.4:2

        at o (WASubContext.js?t=wechat&s=1648259951586&v=2.19.4:2)

    2022-03-26
    有用
    回复

正在加载...

登录 后发表内容