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
What are you really trying to do?
I’m creating a sample for the
samples-rubyrepo demonstrating async/fiber-powered workers usingactivity_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:
sdk-ruby/temporalio/lib/temporalio/internal/bridge.rb
Lines 21 to 26 in ddb2762
Specifically, the
fibers_supportedmethod:sdk-ruby/temporalio/lib/temporalio/internal/bridge.rb
Lines 28 to 33 in ddb2762
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-rubyrepo 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_supportedmethod to correctly account for major versions greater than 3:This preserves the existing requirement of Ruby >= 3.3 while correctly allowing Ruby 4.x.
Environment/Versions
brew install temporal)temporalioRuby SDK 1.3.0Additional context
n/a