diff --git a/package.json b/package.json index 518ac49..ebc6115 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "kube-forwarder", - "version": "1.4.1", - "versionString": "1.4.1", + "version": "1.4.2", "author": "Pixel Point ", "homepage": "https://kube-forwarder.poxelpoint.io", "description": "A tool for managing port forwarding configs for kubernetes clusters", diff --git a/src/renderer/components/Layout/Toolbar.vue b/src/renderer/components/Layout/Toolbar.vue index 935a2a6..a2d101d 100644 --- a/src/renderer/components/Layout/Toolbar.vue +++ b/src/renderer/components/Layout/Toolbar.vue @@ -13,7 +13,7 @@ export default { name: 'Toolbar', computed: { version: function() { - return process.env.NODE_ENV === 'test' ? '0.0.0' : packageJs.versionString + return process.env.NODE_ENV === 'test' ? '0.0.0' : packageJs.version } }, methods: { diff --git a/src/renderer/lib/k8s-port-forwarding-patch.js b/src/renderer/lib/k8s-port-forwarding-patch.js index a307281..dd4021c 100644 --- a/src/renderer/lib/k8s-port-forwarding-patch.js +++ b/src/renderer/lib/k8s-port-forwarding-patch.js @@ -3,7 +3,7 @@ import querystring from 'querystring' import { WebSocketHandler } from '@kubernetes/client-node/dist/web-socket-handler' import WebSocket from 'isomorphic-ws' -WebSocketHandler.restartableHandleStandardInput = async function (createWS, stdin, streamNum = 0) { +WebSocketHandler.restartableHandleStandardInput = function (createWS, stdin, streamNum = 0) { const tryLimit = 3; let queue = Promise.resolve() let ws = null @@ -19,17 +19,24 @@ WebSocketHandler.restartableHandleStandardInput = async function (createWS, stdi } let i = 0; - for (; i < tryLimit; ++i) { - if (ws && ws.readyState === WebSocket.OPEN) { - ws.send(buff); - break; - } else { - ws = await createWS() + + try { + for (; i < tryLimit; ++i) { + if (ws && ws.readyState === WebSocket.OPEN) { + ws.send(buff); + break; + } else { + ws = await createWS() + } } + } catch (e) { + // TODO: Сonsider to log network errors. + console.error(e) + stdin.end() } if (i >= tryLimit) { - throw new Error("can't send data to ws") + stdin.end() } } @@ -45,7 +52,7 @@ WebSocketHandler.restartableHandleStandardInput = async function (createWS, stdi } export function patchForward (forward) { - forward.portForward = async function (namespace, podName, targetPorts, output, err, input) { + forward.portForward = function (namespace, podName, targetPorts, output, err, input) { if (targetPorts.length === 0) { throw new Error('You must provide at least one port to forward to.') } @@ -85,7 +92,7 @@ export function patchForward (forward) { }) } - await WebSocketHandler.restartableHandleStandardInput(createWebSocket, input, 0) + WebSocketHandler.restartableHandleStandardInput(createWebSocket, input, 0) } } /* eslint-enable */