From 7e51441430c154a8ef8500b9bb8200892f662300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Fri, 19 Nov 2021 01:45:17 +0800 Subject: [PATCH 1/5] run-able code with tryShutdown workaround --- src/server/event-stream-manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/event-stream-manager.ts b/src/server/event-stream-manager.ts index 257acdec..abddf908 100644 --- a/src/server/event-stream-manager.ts +++ b/src/server/event-stream-manager.ts @@ -62,7 +62,7 @@ class EventStreamManager { /** * We emit the login event if current the puppet is logged in. */ - if (this.puppet.logonoff()) { + if (this.puppet.isLoggedIn) { log.verbose('EventStreamManager', 'start() puppet is logged in, emit a login event for downstream') const payload = { From 517b7816a3e6b297f2fa84aec826dc0f1f6f13ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Fri, 19 Nov 2021 01:47:16 +0800 Subject: [PATCH 2/5] reproduce the tryShutdown never resolve bug (#176) --- src/server/puppet-server.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/server/puppet-server.ts b/src/server/puppet-server.ts index 975978ff..d3efc6d5 100644 --- a/src/server/puppet-server.ts +++ b/src/server/puppet-server.ts @@ -181,10 +181,10 @@ export class PuppetServer { this.grpcServer = undefined log.verbose('PuppetServer', 'stop() shuting down gRPC server ...') - // const future = await util.promisify( - // grpcServer.tryShutdown - // .bind(grpcServer), - // )() + const future = await util.promisify( + grpcServer.tryShutdown + .bind(grpcServer), + )() try { await new Promise(resolve => setImmediate(resolve)) @@ -196,7 +196,7 @@ export class PuppetServer { * FIXME: even after called `forceShutdown()`, the `tryShutdown()` can not resolved. * commented out the `await` for now to make it work temporary. */ - // await future + await future } catch (e) { log.warn('PuppetServer', 'stop() gRPC shutdown rejection: %s', (e as Error).message) From beabf6b3cc4b7cccd9f4a989261b641a8a84533b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Fri, 19 Nov 2021 01:47:57 +0800 Subject: [PATCH 3/5] lint --- src/client/puppet-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/puppet-service.ts b/src/client/puppet-service.ts index d8540546..37228999 100644 --- a/src/client/puppet-service.ts +++ b/src/client/puppet-service.ts @@ -321,7 +321,7 @@ export class PuppetService extends PUPPET.Puppet { override async logout (reason?: string): Promise { log.verbose('PuppetService', 'logout(%s)', reason ? `"${reason}"` : '') - super.logout(reason) + await super.logout(reason) try { await util.promisify( From 1f82048a8318425d68829735e4c1587247548e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Fri, 19 Nov 2021 01:48:23 +0800 Subject: [PATCH 4/5] 1.7.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 15cf5aa0..6f47a667 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-puppet-service", - "version": "1.7.3", + "version": "1.7.4", "description": "Puppet Service for Wechaty", "type": "module", "exports": { From e5e5c006290d68751b245e23a1ca75c60156ec02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Fri, 19 Nov 2021 01:48:53 +0800 Subject: [PATCH 5/5] 1.7.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f47a667..d58ff903 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-puppet-service", - "version": "1.7.4", + "version": "1.7.5", "description": "Puppet Service for Wechaty", "type": "module", "exports": {