From d6b847d47210f2cf86a63eb95b3cabfa0877be32 Mon Sep 17 00:00:00 2001 From: Hidenori Sugiyama Date: Sat, 30 May 2020 23:50:45 +0900 Subject: [PATCH] Fixed the race condition during create initial connection. --- src/renderer/lib/k8s-port-forwarding-patch.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/renderer/lib/k8s-port-forwarding-patch.js b/src/renderer/lib/k8s-port-forwarding-patch.js index 287750c..59f442f 100644 --- a/src/renderer/lib/k8s-port-forwarding-patch.js +++ b/src/renderer/lib/k8s-port-forwarding-patch.js @@ -52,7 +52,13 @@ WebSocketHandler.restartableHandleStandardInput = async function (createWS, stdi // It's important to open connection immediately (even without data) for some apps (for example: mariadb) try { - ws = await createWS() + let initialWS = await createWS() + if (!ws) { + ws = initialWS + } else { + // Connection has already been created in processData, so it should not be overwritten. + initialWS.close() + } } catch (e) { console.error(e) }