diff --git a/CHANGELOG.md b/CHANGELOG.md index 954312512..c05d48fe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/sprockets/manifest.rb b/lib/sprockets/manifest.rb index 901331bfc..8eda60e4e 100644 --- a/lib/sprockets/manifest.rb +++ b/lib/sprockets/manifest.rb @@ -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 @@ -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