sprockets-rails icon indicating copy to clipboard operation
sprockets-rails copied to clipboard

rake assets:precompile generates different manifests on each host during deploy

Open mckomo opened this issue 7 years ago • 1 comments

Expected behavior

I am deploying an application using Capistrano to an environment that consists of multiple hosts. Running rake assets:precompile produces sprockets manifests with same fingerprint.

Actual behavior

I am deploying an application using Capistrano to an environment that consists of multiple hosts. Running rake assets:precompile produces sprockets manifests with different fingerprint per host.

System configuration

  • Ruby 2.4.1
  • capistrano (3.8.2)
  • capistrano-bundler (1.2.0)
  • capistrano-passenger (0.2.0)
  • capistrano-rails (1.2.3)
  • rails (4.2.9)
  • rails-deprecated_sanitizer (1.0.3)
  • rails-dom-testing (1.0.8)
  • rails-html-sanitizer (1.0.3)
  • rake (12.0.0)
  • rspec-rails (3.6.0)
  • rvm1-capistrano3 (1.4.0)
  • sass-rails (5.0.6)
  • sequel-rails (0.9.17)
  • sprockets-rails (3.2.0)

Details

During deployment on my env that consists of two hosts I noticed that running rake assets:precompile creates two different manifests thus manifest have different fingerprints. Both manifests list exactly same assets with same fingerprint but the order of that list is different. Also some assets are listed twice (with different fingerprint). Here is extract from deployment log showing that manifest indeed have different fingerprints.

...
01:01 deploy:assets:precompile
      01 /path/to/app/tmp/rvm-auto.sh 2.4.1@sp_ofw bundle exec rake assets:precompile
    ✔ 01 [email protected] 12.112s
    ✔ 01 [email protected] 13.311s
01:15 deploy:assets:backup_manifest
      01 mkdir -p /path/to/app/releases/20170723123223/assets_manifest_backup
    ✔ 01 [email protected] 0.348s
    ✔ 01 [email protected] 0.468s
      02 cp /path/to/app/releases/20170723123223/public/assets/.sprockets-manifest-33a5d9ce1cf5ad47057636ed66bee682.json /path/to/app/releases/20170723123223/assets_manifest_backup
    ✔ 02 [email protected] 0.308s
      03 cp /path/to/app/releases/20170723123223/public/assets/.sprockets-manifest-f8e1151b68829d0c2495a9f89d79e1ca.json /path/to/app/releases/20170723123223/assets_manifest_backup
    ✔ 03 [email protected] 0.523s
...

Here are links to those manifests:

  • host001: https://gist.github.com/mckomo/5ab34dd6833454a41ab6f92aff202a51
  • host002: https://gist.github.com/mckomo/c048227cfdd4d5c820e7ee2e5e61dca8

This problem causes Capistrano rollback fail. Cause cap wants to restore manifest that does not exist on second host (due to different fingerprints).

mckomo avatar Aug 02 '17 13:08 mckomo

Similar problem here, I am using webpacker, and the css compiled on each server has different fingerprints. This causes that sometimes an user access the page through server A and when webpacker css are load, the request goes through server B, so it returns 404 because it exists with different name(different fingerprint) in that server.

Did you find a solution for this @mckomo ?

jplethier avatar Nov 07 '17 15:11 jplethier