wechaty/puppet-service

log instead of throw new Error when receiving unknown events

hcfw007 opened this issue · 6 comments

In current wechaty-puppet-service code, we throw an Error when receiving unknown grpc event:

throw new Error('eventType ' + type + ' unsupported! (code should not reach here)')

This error won't be caught by error listener and will break the system. If the bot has registered unhandled error listener on process, the puppet-service event listener will break and no futher events can be processed, which will result in system reset by watch dog. If there is no unhadled error lisener registered, the process will exit directly.

Thus we should change it by logging the error, or emit an error event. Since there might be new events in new versions of puppet and this will break the system for people using older versions.

huan commented

I'd like to accept a Pull Request to make it a soft log instead of a hard exception.

Issue closed since PR has been merged.

When I try to run npm install, an error occursl TypeError: Cannot use 'in' operator to search for 'port' in undefined

当我尝试运行 npm install 时,出现错误 TypeError:无法使用“in”运算符在 undefined 中搜索“port”

me too

我想接受拉取请求以使其成为软日志而不是硬异常。

你好 我也有这样的问题
日志:
10:46:13 INFO PuppetSkeleton start()
10:46:13 INFO PuppetService start() instanciating GrpcManager ...
10:46:13 INFO PuppetService start() instanciating GrpcManager ... done
10:46:13 INFO PuppetService start() setting up bridge grpc event stream ...
10:46:13 INFO PuppetService start() setting up bridge grpc event stream ... done
10:46:13 INFO PuppetService start() starting grpc manager...
10:46:13 WARN last event was 1711622773.979 seconds ago, will not request event cache
10:46:13 WARN GrpcManager initClient() TLS: disabled (INSECURE)
10:46:13 INFO GrpcManager startStream() connecting event stream with account undefined and seq undefined
/workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/subchannel-address.ts:40
return 'port' in address;
^
TypeError: Cannot use 'in' operator to search for 'port' in undefined
at isTcpSubchannelAddress (/workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/subchannel-address.ts:40:16)
at interleaveAddressFamilies (/workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/load-balancer-pick-first.ts:145:27)
at PickFirstLoadBalancer.updateAddressList (/workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/load-balancer-pick-first.ts:533:25)
at ChildLoadBalancerHandler.updateAddressList (/workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/load-balancer-child-handler.ts:137:19)
at onSuccessfulResolution (/workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/resolving-load-balancer.ts:302:34)
at processTicksAndRejections (node:internal/process/task_queues:85:22)

我想接受拉取请求以使其成为软日志而不是硬异常。

你好 我也有这样的问题 日志: 10:46:13 INFO PuppetSkeleton start() 10:46:13 INFO PuppetService start() instanciating GrpcManager ... 10:46:13 INFO PuppetService start() instanciating GrpcManager ... done 10:46:13 INFO PuppetService start() setting up bridge grpc event stream ... 10:46:13 INFO PuppetService start() setting up bridge grpc event stream ... done 10:46:13 INFO PuppetService start() starting grpc manager... 10:46:13 WARN last event was 1711622773.979 seconds ago, will not request event cache 10:46:13 WARN GrpcManager initClient() TLS: disabled (INSECURE) 10:46:13 INFO GrpcManager startStream() connecting event stream with account undefined and seq undefined /workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/subchannel-address.ts:40 return 'port' in address; ^ TypeError: Cannot use 'in' operator to search for 'port' in undefined at isTcpSubchannelAddress (/workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/subchannel-address.ts:40:16) at interleaveAddressFamilies (/workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/load-balancer-pick-first.ts:145:27) at PickFirstLoadBalancer.updateAddressList (/workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/load-balancer-pick-first.ts:533:25) at ChildLoadBalancerHandler.updateAddressList (/workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/load-balancer-child-handler.ts:137:19) at onSuccessfulResolution (/workspaces/workpro-getting-started/node_modules/@grpc/grpc-js/src/resolving-load-balancer.ts:302:34) at processTicksAndRejections (node:internal/process/task_queues:85:22)

怎么解决的?