fix: LiveQuery server is not shut down properly when handleShutdown is called (#8491)

This commit is contained in:
Daniel
2023-06-08 19:04:49 +10:00
committed by GitHub
parent 3ea1ace631
commit 967700bdbc
5 changed files with 63 additions and 4 deletions

View File

@@ -93,6 +93,21 @@ class ParseLiveQueryServer {
}
this._createSubscribers();
}
async shutdown() {
if (this.subscriber.isOpen) {
await Promise.all([
...[...this.clients.values()].map(client => client.parseWebSocket.ws.close()),
this.parseWebSocketServer.close(),
...Array.from(this.subscriber.subscriptions.keys()).map(key =>
this.subscriber.unsubscribe(key)
),
this.subscriber.close?.(),
]);
}
this.subscriber.isOpen = false;
}
_createSubscribers() {
const messageRecieved = (channel, messageStr) => {
logger.verbose('Subscribe message %j', messageStr);