Return instead of yield from Concurrent::Promise (Ruby 3.1 compat) #720
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So i have to admit I don't fully understand what's going nor how it even worked until now.
While testing ruby 3.1.0-dev on a Rails app using sprockets 4.0.2, I get the following error:
I dug into
concurrent-ruby
and somehow thewait!
on the promise is supposed to return multiple values, but simply return nil.I think it's caused by the fact that we
yield
when we're supposed to return, so we're somehow interupting the flow.But looking at the original code I don't even get how it's supposed to work in the first place:
The block passed to
Concurrent::Promise.execute
executes in a background thread, so there's no-one toyield
to.What's weird is that the thread is like immediately killed, there's no backtraces or anything, so that might be a Ruby bug of some sort.
Either way, we should return rather than yield.