From 5dd00d4eb94ae222d58f1c285bf91de0ad7c927d Mon Sep 17 00:00:00 2001 From: Nick Mitchell Date: Sun, 20 Dec 2020 14:27:12 -0500 Subject: [PATCH] fix(plugins/plugin-kubectl): plugin-kubectl's fetch-file, when using electron, does not have error handling Fixes #6426 --- plugins/plugin-kubectl/src/lib/util/fetch-file.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/plugin-kubectl/src/lib/util/fetch-file.ts b/plugins/plugin-kubectl/src/lib/util/fetch-file.ts index 9a3377f4779..5d655e0d63c 100644 --- a/plugins/plugin-kubectl/src/lib/util/fetch-file.ts +++ b/plugins/plugin-kubectl/src/lib/util/fetch-file.ts @@ -72,6 +72,8 @@ async function _needle({ qexec }: REPL, method: 'get', url: string): Promise<{ s redirect: 'follow' }) + request.on('error', reject) + request.on('response', response => { const statusCode = response.statusCode debug('got response', statusCode) @@ -103,7 +105,7 @@ async function _needle({ qexec }: REPL, method: 'get', url: string): Promise<{ s } } -async function fetchRemote (repl: REPL, url: string) { +async function fetchRemote(repl: REPL, url: string) { const fetchOnce = () => _needle(repl, 'get', url).then(_ => _.body) const retry = (delay: number) => async (err: Error) => { @@ -172,7 +174,7 @@ export async function fetchRawFiles(args: Arguments, filepath: stri await args.REPL.rexec<{ data?: string; isDirectory?: boolean }>(`vfs fstat ${path} --with-data`) ).content - if (resourceStats.isDirectory) { + if (resourceStats.isDirectory) { return args.REPL.rexec<{ path: string }[]>( `vfs ls ${join(path, isRecursive(args) ? '/**/*.yaml' : '/*.yaml')} --with-data` )