Terminate all directory searches if any fail

@bolinfest: I was seeing exceptions after the test terminated due to
one of the searches still running. I think since the promise rejects
with “all” semantics that we should cancel any other searches when one
fails. I wouldn’t expect them to continue if the promise is no longer
unresolved.
This commit is contained in:
Nathan Sobo
2015-09-03 16:55:30 -06:00
parent e343125486
commit f77cb3786c
2 changed files with 21 additions and 3 deletions

View File

@@ -904,7 +904,12 @@ class Workspace extends Model
resolve('cancelled')
else
resolve(null)
searchPromise.then(onSuccess, reject)
onFailure = ->
promise.cancel() for promise in allSearches
reject()
searchPromise.then(onSuccess, onFailure)
cancellablePromise.cancel = ->
isCancelled = true
# Note that cancelling all of the members of allSearches will cause all of the searches