SequenceType.traverse(...) - crash when a produced Future fails
darrenclark opened this issue · 3 comments
darrenclark commented
Using SequenceType.traverse(...)
with a large enough sequence (around 200 - 300 items in my testing on the iOS simulator) causes a crash if one of the produced Future
s fails. Interestingly enough, it does not crash if all Future
s succeed.
Specifically, it causes a stack overflow. I'm wondering if it is related to #101?
Here's snippet of code that demonstrates the issue:
struct ExampleError: ErrorType {}
let items = Array(0 ..< 1000)
let f: Future<[Int], ExampleError> = items.traverse { i in
let promise = Promise<Int, ExampleError>()
if i == 289 {
dispatch_async(dispatch_get_main_queue()) {
promise.failure(ExampleError())
}
} else {
dispatch_async(dispatch_get_main_queue()) {
promise.success(i + 1)
}
}
return promise.future
}
Thomvis commented
Sorry for the silence. I think this issue has been resolved in the latest beta (4.0.0-beta.2). Would be great if you could check this!
Thomvis commented
Closing this issue now, since I believe this has been resolved in BrightFutures 4.
darrenclark commented
(Sorry for the delay in getting back to you.) Great, thanks!