Merge pull request #1467 from murgatroid99/grpc-js_tryShutdown_fix

grpc-js: server: cull closed sessions from list, check for closed in tryShutdown
This commit is contained in:
Michael Lumish 2020-06-15 15:02:03 -07:00 committed by GitHub
commit a6101f3d6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -500,10 +500,11 @@ export class Server {
}
}
// If any sessions are active, close them gracefully.
pendingChecks += this.sessions.size;
this.sessions.forEach((session) => {
session.close(maybeCallback);
if (!session.closed) {
pendingChecks += 1;
session.close(maybeCallback);
}
});
if (pendingChecks === 0) {
callback();
@ -608,6 +609,10 @@ export class Server {
}
this.sessions.add(session);
session.on('close', () => {
this.sessions.delete(session);
});
});
}
}