CheckoutV2: When WebSocket disconnects, we should continue polling via XHR (#5165)

* When WebSocket disconnects, we should continue polling via XHR

* Update BTCPayServer/wwwroot/checkout-v2/checkout.js

Co-authored-by: d11n <mail@dennisreimann.de>

---------

Co-authored-by: d11n <mail@dennisreimann.de>
This commit is contained in:
Lee Salminen 2023-07-11 13:56:13 -06:00 committed by GitHub
parent b5f0924651
commit fd6d361e1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -265,6 +265,7 @@ function initApp() {
}
},
listenIn () {
const self = this;
let socket = null;
const updateFn = this.fetchData;
const supportsWebSockets = 'WebSocket' in window && window.WebSocket.CLOSING === 2;
@ -279,6 +280,9 @@ function initApp() {
socket.onerror = function (e) {
console.error('Error while connecting to websocket for invoice notifications (callback):', e);
};
socket.onclose = function () {
self.pollUpdates(2000, socket);
};
}
catch (e) {
console.error('Error while connecting to websocket for invoice notifications', e);