Disconnect from socket faster on loss of network access (#1512)

* Disconnect from socket faster on complete loss of network access

Today we wait for a keepalive request to fail; this change forces
disconnect in the case that the browser tells us that we're now offline.

FREEBIE

* MessageReceiver: don't react to errors after explicit close()

FREEBIE
This commit is contained in:
Scott Nonnenberg 2017-09-28 13:12:43 -07:00 committed by GitHub
parent b0f9644c14
commit 6323f598b5
3 changed files with 41 additions and 8 deletions

View file

@ -38394,6 +38394,7 @@ MessageReceiver.prototype.extend({
this.incoming = [this.pending];
},
close: function() {
this.calledClose = true;
this.socket.close(3000, 'called close');
return this.drain();
},
@ -38407,7 +38408,17 @@ MessageReceiver.prototype.extend({
return Promise.all(this.dispatchEvent(event));
},
onclose: function(ev) {
console.log('websocket closed', ev.code, ev.reason || '');
console.log(
'websocket closed',
ev.code,
ev.reason || '',
'calledClose:',
this.calledClose
);
if (this.calledClose) {
return;
}
if (ev.code === 3000) {
return;
}