Open bewatts opened 20 hours ago
Thanks for your report, I'll take a look.
Do you mind explaining this line of code:
irb(main):008* throw e
in other words, what are your intention of using throw without catch?
Oh, just explanatory, non interesting to the example. This was my attempt to show the simplest example that re-created what I'm seeing my production code, which is erroring on calling the Sync method (without the annotation keyword arg).
Okay, I see. I think maybe you meant to use raise
instead of throw
- even if it's just the example code... it threw me off :)
Okay, I think the issue is with fiber_hook
and/or fiber-annotate
. Let me take a look.
Reproduction:
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'async'
gem 'fiber_hook'
end
require 'fiber_hook'
Sync{'?? wat?? '}
The fiber-hook
gem might be fixable by passing through arguments, however, I advise you to avoid it, and probably also request_store-fibers
too if possible. Instead, use Fiber#storage
feature in Ruby.
My general advice would be:
RequestStore
by itself is okay, but it won't inherit to child Async
tasks (or threads).RequestStore.store[x]
with Fiber[x]
.require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'async'
gem 'request_store'
gem 'stringio'
end
RequestStore.store[:foo] = 'bar'
puts "RequestStore.store[:foo] = #{RequestStore.store[:foo].inspect} (outer)"
Fiber[:foo] = 'bar'
puts "Fiber[:foo] = #{Fiber[:foo].inspect} (outer)"
puts "Async do ..."
Async do
puts "RequestStore.store[:foo] = #{RequestStore.store[:foo].inspect} (inner)"
puts "Fiber[:foo] = #{Fiber[:foo].inspect} (inner)"
end
I'm in the middle of upgrading a rails app from rails 6.1.7.9 to 7.2, and getting some very odd behavior when I'm trying to upgrade the async gem from 2.5.1 to 2.20.0. I'm seeing similar behavior on versions ~2.6 as well. My use of the Sync method seems consistent with the documentation.
On version 2.5.1:
On version 2.20.0:
StackTrace