Skip to content

[Bug] Using activity_executor :fiber in Ruby 4.0 or later raises a fibers unsupported error #416

@jasonligg

Description

@jasonligg

What are you really trying to do?

I’m creating a sample for the samples-ruby repo demonstrating async/fiber-powered workers using activity_executor :fiber.

Describe the bug

When using Ruby 4.0 or later and configuring a Temporal activity with activity_executor :fiber, the SDK raises an error indicating that fibers are not supported. This is incorrect, as fibers are supported in Ruby 4.x.

The issue appears to originate from this check:

def self.assert_fiber_compatibility!
return unless Fiber.current_scheduler && !fibers_supported
raise 'Temporal SDK only supports fibers with Ruby 3.3 and newer, ' \
'see https://github.com/temporalio/sdk-ruby/issues/162'
end

Specifically, the fibers_supported method:

def self.fibers_supported # rubocop:disable Naming/PredicateMethod
# We do not allow fibers on < 3.3 due to a bug we still need to dig
# into: https://github.com/temporalio/sdk-ruby/issues/162
major, minor = RUBY_VERSION.split('.').take(2).map(&:to_i)
!major.nil? && major >= 3 && !minor.nil? && minor >= 3
end

The version check only evaluates the minor version and assumes a major version of 3, which causes it to incorrectly reject Ruby 4.x.

Expected behavior

Fiber-based activity executors should work on Ruby 3.3+ and all Ruby 4.x versions.

Minimal Reproduction

Here is a fork of the samples-ruby repo with a new sample I am working on that demonstrates the issue:

https://github.com/jasonligg/temporal-samples-ruby/tree/04-12-fiber_activity_sample/fiber_activity

Running the sample as-is reproduces the error.

If you uncomment this block (which monkey-patches the version check), the example works correctly:

https://github.com/jasonligg/temporal-samples-ruby/blob/00100335e19d973a07c13e46ea95ca713928e04e/fiber_activity/worker.rb#L12-L25

Proposed Solution

Update the fibers_supported method to correctly account for major versions greater than 3:

def self.fibers_supported
  major, minor = RUBY_VERSION.split('.').take(2).map(&:to_i)
  return false if major.nil? || minor.nil?

  major > 3 || (major == 3 && minor >= 3)
end

This preserves the existing requirement of Ruby >= 3.3 while correctly allowing Ruby 4.x.

Environment/Versions

  • OS and processor: M4 Mac, macOS Sequoia 15.6
  • Temporal Version: 2.45.3 (from brew install temporal)
  • SDK: temporalio Ruby SDK 1.3.0
  • Ruby: 4.0.1
  • Are you using Docker or Kubernetes or building Temporal from source? n/a

Additional context

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions