Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproduce: tryShutdown freeze app #185

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechaty-puppet-service",
"version": "1.7.3",
"version": "1.7.5",
"description": "Puppet Service for Wechaty",
"type": "module",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion src/client/puppet-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export class PuppetService extends PUPPET.Puppet {
override async logout (reason?: string): Promise<void> {
log.verbose('PuppetService', 'logout(%s)', reason ? `"${reason}"` : '')

super.logout(reason)
await super.logout(reason)

try {
await util.promisify(
Expand Down
2 changes: 1 addition & 1 deletion src/server/event-stream-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
10 changes: 5 additions & 5 deletions src/server/puppet-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down