-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Edge promises fail during error handling #659
Comments
In troubleshooting various possible solutions, I have found one for each. undefined method `exception' for Concurrent::Array--- lib/concurrent/edge/promises.rb
+++ lib/concurrent/edge/promises.rb
@@ -981,9 +981,9 @@
# @raise [StandardError] when raising not rejected future
# @return [Exception]
def exception(*args)
raise Concurrent::Error, 'it is not rejected' unless rejected?
- reason = Array(internal_state.reason).compact
+ reason = Array(internal_state.reason).compact.flatten
if reason.size > 1
Concurrent::MultipleErrors.new reason
else
ex = reason[0].exception(*args) This handles deeply nested errors without issue. Thoughts? Will update with other solution shortly. |
undefined method `+' for NilClass--- lib/concurrent/edge/promises.rb
+++ lib/concurrent/edge/promises.rb
@@ -986,9 +986,9 @@
if reason.size > 1
Concurrent::MultipleErrors.new reason
else
ex = reason[0].exception(*args)
- ex.set_backtrace ex.backtrace + caller
+ ex.set_backtrace Array(ex.backtrace) + caller
ex
end
end
Ehh. I'm not sure if this is necessary. I think the root problem might be the documentation/examples that show this contrived usage: Concurrent::Promises.rejected_future(StandardError.new("BOOM")) Explicitly creating and passing around an exception is odd. Is there any real world usage of this? The existing code works fine in this example, which is far more real-world: begin
raise "BOOM"
rescue => e
# do something with e, like log or notify or something
Concurrent::Promises.rejected_future(e)
end Since this exception was actually raised it will have a non-nil backtrace, and work just fine. |
* Now properly handles errors raised within deeply nested futures. * `value!` now properly works with `rejected_future` Fixes ruby-concurrency#659
Submitting a PR shortly |
* Now properly handles errors raised within deeply nested futures. * `value!` now properly works with `rejected_future` Fixes ruby-concurrency#659
Indeed it's strange, but I think it should still work in this case as you have fixed. Thanks. |
As shown, the edge promises fail unexpectedly during error handling. The
explicit_failure
,zipped_explicit
, andzipped_nested
behavior above all seem like bugs. Note there are two separate issues here:.exception
when handling explicitly rejected futures (via.rejected_future
).exception
when handling any failure (explicit or unexpected) that is nested within a zip of at least two levels.Stack traces for each case:
concurrent-ruby
version: 1.0.5concurrent-ruby-ext
installed: noconcurrent-ruby-edge
used: yes (0.3.1)The text was updated successfully, but these errors were encountered: