From 68d7282aa84a8d968995ecfb4bbee865f053ee0b Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Fri, 10 Nov 2017 00:07:06 -0500 Subject: [PATCH] Fixes failed git commands from sticking in the queue --- src/git/git.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/git/git.ts b/src/git/git.ts index cac6c60..8c3fa55 100644 --- a/src/git/git.ts +++ b/src/git/git.ts @@ -84,14 +84,18 @@ async function gitCommandCore(options: GitCommandOptions, ...args: any[]): Promi Logger.log(`Awaiting${command}`); } - const s = await promise; - pendingCommands.delete(command); - - Logger.log(`Completed${command}`); + let data: string; + try { + data = await promise; + } + finally { + pendingCommands.delete(command); + Logger.log(`Completed${command}`); + } - if (opts.encoding === 'utf8' || opts.encoding === 'binary') return s; + if (opts.encoding === 'utf8' || opts.encoding === 'binary') return data; - return iconv.decode(Buffer.from(s, 'binary'), opts.encoding); + return iconv.decode(Buffer.from(data, 'binary'), opts.encoding); } function gitCommandDefaultErrorHandler(ex: Error, options: GitCommandOptions, ...args: any[]): string {