wechaty / puppet-supports

Wechaty Puppet Services (WPS)
https://wechaty.js.org/docs/puppet-services/
Apache License 2.0
33 stars 4 forks source link

[BUG]WorkPro:企业微信报异常退出,“GError: 1 CANCELLED: Call cancelled” #262

Closed ccgulan closed 1 year ago

ccgulan commented 1 year ago

node:events:491 throw er; // Unhandled 'error' event ^

GError: 1 CANCELLED: Call cancelled at callErrorFromStatus (E:\wechat-robot-worpro\node_modules\@grpc\grpc-js\build\src\call.js:31:19) at Object.onReceiveStatus (E:\wechat-robot-worpro\node_modules\@grpc\grpc-js\build\src\client.js:351:73) at Object.onReceiveStatus (E:\wechat-robot-worpro\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:323:181) at E:\wechat-robot-worpro\node_modules\@grpc\grpc-js\build\src\resolving-call.js:93:78 at process.processTicksAndRejections (node:internal/process/task_queues:77:11) for call at at ServiceClientImpl.makeServerStreamRequest (E:\wechat-robot-worpro\node_modules\@grpc\grpc-js\build\src\client.js:334:34) at ServiceClientImpl.event (E:\wechat-robot-worpro\node_modules\@grpc\grpc-js\build\src\make-client.js:105:19) at GrpcManager.startStream (file:///E:/wechat-robot-worpro/node_modules/wechaty-puppet-service/dist/esm/src/client/grpc-manager.js:232:41) at GrpcManager.start (file:///E:/wechat-robot-worpro/node_modules/wechaty-puppet-service/dist/esm/src/client/grpc-manager.js:121:20) at async PuppetService.onStart (file:///E:/wechat-robot-worpro/node_modules/wechaty-puppet-service/dist/esm/src/client/puppet-service.js:110:9) at async PuppetService.start (file:///E:/wechat-robot-worpro/node_modules/wechaty-puppet/node_modules/state-switch/dist/esm/src/service-ctl/service-ctl.js:62:17) at async PuppetService.start (file:///E:/wechat-robot-worpro/node_modules/wechaty-puppet/dist/esm/src/mixins/service-mixin.js:18:13) at async PuppetService.start (file:///E:/wechat-robot-worpro/node_modules/wechaty-puppet/dist/esm/src/mixins/ready-mixin.js:13:13) at async WechatyImpl.start (file:///E:/wechat-robot-worpro/node_modules/wechaty/dist/esm/src/wechaty-mixins/puppet-mixin.js:48:21) at async WechatyImpl.start (file:///E:/wechat-robot-worpro/node_modules/state-switch/dist/esm/src/service-ctl/service-ctl.js:55:21) Emitted 'error' event on WechatyImpl instance at: at WechatyImpl.emit (file:///E:/wechat-robot-worpro/node_modules/wechaty/dist/esm/src/wechaty-mixins/gerror-mixin.js:45:26) at PuppetService. (file:///E:/wechat-robot-worpro/node_modules/wechaty/dist/esm/src/wechaty-mixins/puppet-mixin.js:155:34) at PuppetService.emit (node:events:525:35) at PuppetService.emit (file:///E:/wechat-robot-worpro/node_modules/wechaty-puppet/dist/esm/src/puppet/puppet-skeleton.js:107:22) at GrpcManager. (file:///E:/wechat-robot-worpro/node_modules/wechaty-puppet-service/dist/esm/src/client/puppet-service.js:162:18) at GrpcManager.emit (node:events:513:28) at ClientReadableStreamImpl. (file:///E:/wechat-robot-worpro/node_modules/wechaty-puppet-service/dist/esm/src/client/grpc-manager.js:308:44) at ClientReadableStreamImpl.emit (node:events:525:35) at Object.onReceiveStatus (E:\wechat-robot-worpro\node_modules\@grpc\grpc-js\build\src\client.js:351:28) at Object.onReceiveStatus (E:\wechat-robot-worpro\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:323:181) { code: 1, details: 'Call cancelled' }

Node.js v18.14.0

hcfw007 commented 1 year ago

这个是请求过程中 grpc 连接断开的错误。grpc 连接断开是正常情况,应该设计合理的重连、重试机制。

ccgulan commented 1 year ago

这个是请求过程中 grpc 连接断开的错误。grpc 连接断开是正常情况,应该设计合理的重连、重试机制。

@hcfw007 这个API中有示例吗,如何检测到grpc异常,如何重连?

hcfw007 commented 1 year ago

首先应该监听bot的error事件,否则随便出一个错误就崩溃了,而出错误其实是很常见的情况。 然后针对特定类型的错误码进行bot的重启(注意需要限流,因为网络出问题的时候可能一下很多请求失败) 我们这边触发重启的错误码是

const resetErrorList = [
  '14 UNAVAILABLE',
  'no grpc manager',
  'NO CLIENT',
];

重启的方法

await bot.reset();

请参考

hcfw007 commented 1 year ago

长时间未回复,Issue关闭。