{"action":"created","issue":{"url":"https://api.github.com/repos/rails/sprockets/issues/74","labels_url":"https://api.github.com/repos/rails/sprockets/issues/74/labels{/name}","comments_url":"https://api.github.com/repos/rails/sprockets/issues/74/comments","events_url":"https://api.github.com/repos/rails/sprockets/issues/74/events","html_url":"https://github.com/rails/sprockets/issues/74","id":94973260,"number":74,"title":"Uglifier compressor generates random variable names under 3.x","user":{"login":"amw","id":29783,"avatar_url":"https://avatars.githubusercontent.com/u/29783?v=3","gravatar_id":"","url":"https://api.github.com/users/amw","html_url":"https://github.com/amw","followers_url":"https://api.github.com/users/amw/followers","following_url":"https://api.github.com/users/amw/following{/other_user}","gists_url":"https://api.github.com/users/amw/gists{/gist_id}","starred_url":"https://api.github.com/users/amw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amw/subscriptions","organizations_url":"https://api.github.com/users/amw/orgs","repos_url":"https://api.github.com/users/amw/repos","events_url":"https://api.github.com/users/amw/events{/privacy}","received_events_url":"https://api.github.com/users/amw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rails/sprockets/milestones/4","html_url":"https://github.com/rails/sprockets/milestones/3.x","labels_url":"https://api.github.com/repos/rails/sprockets/milestones/4/labels","id":1253820,"number":4,"title":"3.x","description":null,"creator":{"login":"rafaelfranca","id":47848,"avatar_url":"https://avatars.githubusercontent.com/u/47848?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"open_issues":10,"closed_issues":0,"state":"open","created_at":"2015-08-13T15:40:20Z","updated_at":"2015-08-20T20:51:32Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2015-07-14T15:32:27Z","updated_at":"2015-10-26T10:51:14Z","closed_at":null,"body":"This one is a bit complex, but I'll try to provide as much detail as possible. \r\n\r\nAfter upgrading from sprockets 2.12.4 to 3.0.3 (or 3.2.0) I get different digests for many of my JS files on different production machines. If I disable Uglifier compression in Rails config then the problem goes away and the digests are the same. With Uglifier enabled the differences look like this:\r\n\r\nInstance 1\r\n```\r\n(function(){$(function(){var t,e,i,n,o,r,a,s,l;if\r\n```\r\n\r\nInstance 2\r\n```\r\n(function(){$(function(){var e,t,r,i,n,o,a,s,h;if\r\n```\r\n\r\nI have looked on the whole files and the only differences are in variable names and function parameter names.\r\n\r\nThe other relevant gems in my setup are:\r\n\r\n```\r\n    execjs (2.5.2)\r\n    libv8 (3.16.14.11)\r\n    therubyracer (0.12.2)\r\n    uglifier (2.7.1)\r\n    sprockets-rails (2.3.2)\r\n```\r\n\r\nKeeping all these gem versions constant and only changing `sprockets` version the problem is introduced somewhere between 2.12.4 and 3.0.3. It might be an issue of `sprockets-rails` though - maybe it doesn't handle `sprockets` 3.x well yet.\r\n\r\nDon't know if it matters, but these JS files are added to sprockets like this:\r\n\r\n```\r\n# config/initializers/assets.rb\r\n\r\nRails.application.config.assets.precompile += Rails\r\n  .root\r\n  .join(\"app/assets/javascripts/page_scripts\")\r\n  .children(false)\r\n  .map {|file|\r\n    file = file.to_s\r\n      .sub(/\\.erb\\z/, '')\r\n      .sub(/\\.coffee\\z/, '')\r\n    \"page_scripts/#{file}\"\r\n  }\r\n```"},"comment":{"url":"https://api.github.com/repos/rails/sprockets/issues/comments/151098241","html_url":"https://github.com/rails/sprockets/issues/74#issuecomment-151098241","issue_url":"https://api.github.com/repos/rails/sprockets/issues/74","id":151098241,"user":{"login":"amw","id":29783,"avatar_url":"https://avatars.githubusercontent.com/u/29783?v=3","gravatar_id":"","url":"https://api.github.com/users/amw","html_url":"https://github.com/amw","followers_url":"https://api.github.com/users/amw/followers","following_url":"https://api.github.com/users/amw/following{/other_user}","gists_url":"https://api.github.com/users/amw/gists{/gist_id}","starred_url":"https://api.github.com/users/amw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amw/subscriptions","organizations_url":"https://api.github.com/users/amw/orgs","repos_url":"https://api.github.com/users/amw/repos","events_url":"https://api.github.com/users/amw/events{/privacy}","received_events_url":"https://api.github.com/users/amw/received_events","type":"User","site_admin":false},"created_at":"2015-10-26T10:51:14Z","updated_at":"2015-10-26T10:51:14Z","body":"For a little bit more context:\r\n\r\nThere are two main strategies for asset compilation:\r\n1. Asset compilation can be performed on a single developer/deploying machine and the compiled assets are then pushed to all the production servers. No problem here.\r\n2. Only asset sources can be copied to production machines and the deploy process will compile the assets independently on each production server. This is how `cap production deploy:compile_assets` works. This is what I use.\r\n\r\nNow with sprockets 3.x the `uglifier` on these different machines generates different function argument names. This causes the asset hashes to differ.\r\n\r\nSo now one production web server sends html file with request for `asset-abc.js`. User's web browser sends request for that JS file, but it goes to a different web server. That web server has only `asset-zxc.js` available so it responds with 404 error code.\r\n\r\nI use capistrano and bundler so the gem versions are all the same on each production server. Somehow the shortened function arguments produced by `uglifier` under sprockets 3.x are not generated deterministically."}}