Skip to content

Edge promises fail during error handling #659

Closed
@hobodave

Description

@hobodave
def normal
  Concurrent::Promises.future { 1 }
end

def fulfilled
  Concurrent::Promises.fulfilled_future(1)
end

def unexpected_failure
  Concurrent::Promises.future { raise "BOOM" }
end

def explicit_failure
  Concurrent::Promises.rejected_future(StandardError.new("BOOM"))
end

def zipped_unexpected
  Concurrent::Promises.zip_futures(unexpected_failure)
end

def zipped_explicit
  Concurrent::Promises.zip_futures(explicit_failure)
end

def zipped_nested
  Concurrent::Promises.zip_futures(zipped_unexpected)
end

normal.value!               # 1
fulfilled.value!            # 1
unexpected_failure.value!   # RuntimeError: BOOM
explicit_failure.value!     # NoMethodError: undefined method `+' for nil:NilClass
zipped_unexpected.value!    # RuntimeError: BOOM
zipped_explicit.value!      # NoMethodError: undefined method `+' for nil:NilClass
zipped_nested.value!        # NoMethodError: undefined method `exception' for [#<RuntimeError: BOOM>]:Concurrent::Array

As shown, the edge promises fail unexpectedly during error handling. The explicit_failure, zipped_explicit, and zipped_nested behavior above all seem like bugs. Note there are two separate issues here:

  1. The behavior of .exception when handling explicitly rejected futures (via .rejected_future)
  2. The behavior of .exception when handling any failure (explicit or unexpected) that is nested within a zip of at least two levels.

Stack traces for each case:

NoMethodError: undefined method `+' for nil:NilClass
	from /Users/davida/.rvm/gems/jruby-9.1.7.0@deal-management-api/gems/concurrent-ruby-edge-0.3.1/lib/concurrent/edge/promises.rb:990:in `exception'
	from /Users/davida/.rvm/gems/jruby-9.1.7.0@deal-management-api/gems/concurrent-ruby-edge-0.3.1/lib/concurrent/edge/promises.rb:1204:in `wait_until_resolved!'
	from /Users/davida/.rvm/gems/jruby-9.1.7.0@deal-management-api/gems/concurrent-ruby-edge-0.3.1/lib/concurrent/edge/promises.rb:975:in `value!'
NoMethodError: undefined method `exception' for [#<RuntimeError: BOOM>]:Concurrent::Array
	from /Users/davida/.rvm/gems/jruby-9.1.7.0@deal-management-api/gems/concurrent-ruby-edge-0.3.1/lib/concurrent/edge/promises.rb:989:in `exception'
	from /Users/davida/.rvm/gems/jruby-9.1.7.0@deal-management-api/gems/concurrent-ruby-edge-0.3.1/lib/concurrent/edge/promises.rb:1204:in `wait_until_resolved!'
	from /Users/davida/.rvm/gems/jruby-9.1.7.0@deal-management-api/gems/concurrent-ruby-edge-0.3.1/lib/concurrent/edge/promises.rb:975:in `value!'

  • JRuby 9.1.7.0
  • concurrent-ruby version: 1.0.5
  • concurrent-ruby-ext installed: no
  • concurrent-ruby-edge used: yes (0.3.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug in the library or documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions