From a2ab84c3e6bd997ba07ebb86f3fa1176c63c5765 Mon Sep 17 00:00:00 2001 From: joshaber Date: Mon, 4 Jan 2016 13:36:13 -0500 Subject: [PATCH] Catch errors that are thrown while we're refreshing. --- src/git-repository-async.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/git-repository-async.js b/src/git-repository-async.js index 1bc0c1684..95bb407d8 100644 --- a/src/git-repository-async.js +++ b/src/git-repository-async.js @@ -810,7 +810,18 @@ export default class GitRepositoryAsync { const branch = this._refreshBranch() const aheadBehind = branch.then(branchName => this._refreshAheadBehindCount(branchName)) - return Promise.all([status, branch, aheadBehind]).then(_ => null) + return Promise.all([status, branch, aheadBehind]) + .then(_ => null) + // Because all these refresh steps happen asynchronously, it's entirely + // possible the repository was destroyed while we were working. In which + // case we should just swallow the error. + .catch(e => { + if (this._isDestroyed()) { + return null + } else { + return Promise.reject(e) + } + }) } // Get the NodeGit repository for the given path.