-
Notifications
You must be signed in to change notification settings - Fork 646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add raise_on_missing_assets and exceptions on missing assets #1094
Conversation
@unixmonkey any chance you could approve CI on this PR? I've tested it locally but I'd love to confirm |
Caution We've discovered that running this branch in production caused a very high increase in memory use. We're still investigating why but my initial guess is that I will update this PR once we figure this out |
Sprockets::Railtie.build_environment(Rails.application).find_asset(path, :base_path => Rails.application.root.to_s) This code leaks memory like crazy in sprockets 3.7.2 running in production mode (with compiled assets). It leaks on the Test: # in Rails console or rake task with Rails environment
require 'get_process_mem' # @see /~https://github.com/zombocom/get_process_mem
def measure
memory_before = GetProcessMem.new.mb
result = yield
ensure
memory_after = GetProcessMem.new.mb
memory_diff = memory_after - memory_before
puts "[Memory] before: #{memory_before} after: #{memory_after} diff: #{memory_diff}"
result
end
path = 'application.css'
puts "With fresh environment"
10.times { measure { Sprockets::Railtie.build_environment(Rails.application).find_asset(path, :base_path => Rails.application.root.to_s) } }
puts ""
puts "With reused environment"
env = Sprockets::Railtie.build_environment(Rails.application)
10.times { measure { env.find_asset(path, :base_path => Rails.application.root.to_s) } } Result:
I believe this bug is not triggered normally because in the current This issue will also affect #1007. It's already late so I'll look into implementing a proper patch tomorrow. There's still a small memory leak somewhere that doesn't happen on |
On further investigation: fixing recreating |
I've fixed the rubocop issue that has caused the CI run to fail and have confirmed locally that it works. Apologies for missing this! |
@mileszs @unixmonkey -- I would love to see if the tests runs on this at least. |
I see there are conflicts already with the current master branch. Are you guys interested in this PR at all or should I close it? |
@d4rky-pl I am interested in this one as long as it's opt-in, and you've figured out the leak/bloat issues, which it sounds like you have. |
32cb0d0
to
9adfa7a
Compare
@unixmonkey it was opt-in from the start to avoid it being a breaking change. The leak/bloat issues are already solved and we've been running this version of the library in production for almost a month now with no problems. I've rebased the branch with latest |
This is now released in version 2.8.0 of the Wicked PDF gem. Thank you so much for your help! Please let me know if you have any issues! |
This broke production for me with a
So it looks like at least the branch of Must the extension always be added then and the README should be updated? |
Yes, I think because
Maybe we can do something similar here? I haven't looked into it very much yet. |
We also ran into a = wicked_pdf_stylesheet_link_tag "https://s3-<redacted>/application.css" Before, |
Ouch! I see my changes have introduced more than one bug 💔 @unixmonkey I'll try to support you on these sometime this week |
Sent a PR with a fix in #1115 |
This may come late but I also get an error I am positive |
Thanks @d4rky-pl Just one more query! |
Currently WickedPDF will fail silently in most cases where assets are not available. This may not be ideal for certain scenarios where the generated PDFs must always be built properly.
This PR introduces two changes:
MissingLocalAsset
andMissingRemoteAsset
and a new config optionraise_on_missing_assets
to fail when the assets are not available