Skip to content

Commit

Permalink
Return instead of yield from Concurrent::Promise
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Oct 13, 2021
1 parent 4f07fb9 commit 6fcc0d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Get upgrade notes from Sprockets 3.x to 4.x at https://github.com/rails/sprocket

## Master

- Fix `Manifest#find` yielding from a Promise causing issue on Ruby 3.1.0-dev. [#720](https://github.com/rails/sprockets/pull/720)
- Better detect the ERB version to avoid deprecation warnings. [#719](https://github.com/rails/sprockets/pull/719)
- Allow assets already fingerprinted to be served through `Sprockets::Server`
- Do not fingerprint files that already contain a valid digest in their name
Expand Down
11 changes: 6 additions & 5 deletions lib/sprockets/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def files
# Public: Find all assets matching pattern set in environment.
#
# Returns Enumerator of Assets.
def find(*args)
def find(*args, &block)
unless environment
raise Error, "manifest requires environment for compilation"
end
Expand All @@ -122,12 +122,13 @@ def find(*args)
environment = self.environment.cached
promises = args.flatten.map do |path|
Concurrent::Promise.execute(executor: executor) do
environment.find_all_linked_assets(path) do |asset|
yield asset
end
environment.find_all_linked_assets(path).to_a
end
end
promises.each(&:wait!)

promises.each do |promise|
promise.value!.each(&block)
end

nil
end
Expand Down

0 comments on commit 6fcc0d1

Please sign in to comment.