Merge pull request #393 from siikamiika/reconnect-frontend-api-sender

reconnect FrontendApiSender after disconnecting
This commit is contained in:
siikamiika 2020-03-08 00:50:24 +02:00 committed by GitHub
commit 4b0dfa92aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,8 @@ class FrontendApiSender {
invoke(action, params, target) { invoke(action, params, target) {
if (this.disconnected) { if (this.disconnected) {
// attempt to reconnect the next time
this.disconnected = false;
return Promise.reject(new Error('Disconnected')); return Promise.reject(new Error('Disconnected'));
} }
@ -70,6 +72,7 @@ class FrontendApiSender {
onDisconnect() { onDisconnect() {
this.disconnected = true; this.disconnected = true;
this.port = null;
for (const id of this.callbacks.keys()) { for (const id of this.callbacks.keys()) {
this.onError(id, 'Disconnected'); this.onError(id, 'Disconnected');