Add brief delay before declaring websocket broken
This commit is contained in:
parent
d8de36b5ac
commit
9de35a6e8b
|
@ -13,7 +13,7 @@
|
||||||
<%def name="page_content()">
|
<%def name="page_content()">
|
||||||
% if expose_websockets and not supervisor_error:
|
% if expose_websockets and not supervisor_error:
|
||||||
<b-notification type="is-warning"
|
<b-notification type="is-warning"
|
||||||
:active="websocketClosed"
|
:active="websocketBroken"
|
||||||
:closable="false">
|
:closable="false">
|
||||||
Server connection was broken - please refresh page to see accurate status!
|
Server connection was broken - please refresh page to see accurate status!
|
||||||
</b-notification>
|
</b-notification>
|
||||||
|
@ -135,7 +135,7 @@
|
||||||
% if expose_websockets and not supervisor_error:
|
% if expose_websockets and not supervisor_error:
|
||||||
|
|
||||||
ThisPageData.ws = null
|
ThisPageData.ws = null
|
||||||
ThisPageData.websocketClosed = false
|
ThisPageData.websocketBroken = false
|
||||||
|
|
||||||
ThisPage.mounted = function() {
|
ThisPage.mounted = function() {
|
||||||
|
|
||||||
|
@ -147,7 +147,14 @@
|
||||||
let that = this
|
let that = this
|
||||||
|
|
||||||
this.ws.onclose = (event) => {
|
this.ws.onclose = (event) => {
|
||||||
that.websocketClosed = true
|
// websocket closing means 1 of 2 things:
|
||||||
|
// - user navigated away from page intentionally
|
||||||
|
// - server connection was broken somehow
|
||||||
|
// only one of those is "bad" and we only want to
|
||||||
|
// display warning in 2nd case. so we simply use a
|
||||||
|
// brief delay to "rule out" the 1st scenario
|
||||||
|
setTimeout(() => { that.websocketBroken = true },
|
||||||
|
3000)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ws.onmessage = (event) => {
|
this.ws.onmessage = (event) => {
|
||||||
|
|
Loading…
Reference in a new issue