From fd6d361e1acb76f27cc09485791a94bd65c1ecf0 Mon Sep 17 00:00:00 2001 From: Lee Salminen Date: Tue, 11 Jul 2023 13:56:13 -0600 Subject: [PATCH] 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 --------- Co-authored-by: d11n --- BTCPayServer/wwwroot/checkout-v2/checkout.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BTCPayServer/wwwroot/checkout-v2/checkout.js b/BTCPayServer/wwwroot/checkout-v2/checkout.js index 1904eb262..ffab8183d 100644 --- a/BTCPayServer/wwwroot/checkout-v2/checkout.js +++ b/BTCPayServer/wwwroot/checkout-v2/checkout.js @@ -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);