Handle onMessage errors when client is not connected

Reviewed By: lblasa

Differential Revision: D47397641

fbshipit-source-id: ac9c057050a3bac0c5149f5ce2998657fededb61
This commit is contained in:
Andrey Goncharov
2023-07-14 03:31:20 -07:00
committed by Facebook GitHub Bot
parent 257003af42
commit 0345d7d533

View File

@@ -218,6 +218,7 @@ export default abstract class AbstractClient extends EventEmitter {
// get the plugins, and update the UI // get the plugins, and update the UI
async refreshPlugins() { async refreshPlugins() {
try {
const oldBackgroundPlugins = this.backgroundPlugins; const oldBackgroundPlugins = this.backgroundPlugins;
await this.loadPlugins('refresh'); await this.loadPlugins('refresh');
await Promise.all( await Promise.all(
@@ -242,6 +243,13 @@ export default abstract class AbstractClient extends EventEmitter {
} }
}); });
this.emit('plugins-change'); this.emit('plugins-change');
} catch (e) {
if (this.connected) {
throw e;
} else {
console.warn(e);
}
}
} }
onMessage(msg: string) { onMessage(msg: string) {